Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Found the answer in another post:
Workheets("mysheetname").Range("B6:J37").Select "ewan7279" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
run time error 1004 general odbc error excel 2003 vba | Excel Programming | |||
Run Time Error 1004: Application or Object Defined Error | Excel Programming | |||
Run Time 1004 Error: Application or Object Difine Error | Excel Programming | |||
run-time error '1004': Application-defined or object-deifined error | Excel Programming | |||
Application Run Time Error 1004 and Stack Error | Excel Programming |