Run-time error '1004'

E

ewan7279

Hi All,

My code trips up with the error message "Select method of Range class
failed" at the point highlighted below. Any ideas why??

Dim filename1, homefile As Variant

homefile = ActiveWorkbook.Name

MsgBox "Please select the file you wish to open", vbOKOnly, "Select File"
filename1 = Application.GetOpenFilename()
A = MsgBox("Open " & filename1 & "?", vbYesNoCancel, "Open file")
If A = vbNo Then
GoTo ErrorHandler
Exit Sub
Else
If A = vbCancel Then
GoTo ErrorHandler
Exit Sub
End If
End If
Workbooks.OpenText filename1
filename1 = ActiveWorkbook.Name

Workbooks(filename1).Activate
Sheets("mysheetname").Select
Range("B6:J37").Select <= this causes the error
Selection.Copy
Windows(homefile).Activate
Sheets("mysheetname").Select
Range("L11").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
etc etc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top