Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Run-time error '1004'

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Run-time error '1004'

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
run time error 1004 general odbc error excel 2003 vba Mentos Excel Programming 5 January 24th 11 02:56 PM
Run Time Error 1004: Application or Object Defined Error BEEJAY Excel Programming 4 October 18th 06 04:19 PM
Run Time 1004 Error: Application or Object Difine Error BEEJAY Excel Programming 0 October 17th 06 10:45 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Application Run Time Error 1004 and Stack Error ExcelMonkey[_190_] Excel Programming 9 February 11th 05 04:48 PM


All times are GMT +1. The time now is 11:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"