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
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