I'm trying to do something pretty simple in Excel - just prompt for a filename, copy the contents (keeping the formatting) of a worksheet in that file into a sheet with the same name in the currently open workbook. I keep getting "Subscript out of range" on the line "Workbooks(oldfname).Sheets("Player List").Range("A1:Z100").Copy". Here's the code:
Private Sub CopyPlayerInfoButton_Click()
Dim fnameWithPath, oldfname As String
oldfname = Application.GetOpenFilename(, , "Old ePonger file")
Sheets("Player List").Visible = True
Sheets("Player List").Activate
Application.CutCopyMode = False
Workbooks(oldfname).Sheets("Player List").Range("A1:Z100").Copy
Range("A1:Z100").Select
ActiveSheet.Paste
End Sub
Any help would be appreciated, thanks!