try deleting it. your next line is another "select" so it does nothing anyway
This is a discussion on workbooks.open: select method of range class failed within the Excel Questions forums, part of the Question Forums category; Hi All, Have been searching the web for a solution to this problem but nothing working for me. Basically I ...
Hi All,
Have been searching the web for a solution to this problem but nothing working for me.
Basically I recorded a macro which copies cell values into another workbook. This runs fine as a stand alone marco but I have tried to add it to a larger piece of code which returns the error: 'select method of range class failed'
Debug highlights: Range("A2").Select
Any help appreciated.
Code:Sub Invoice_List() ' ' Invoice_List Macro Range("A26:G26").Select Selection.Copy Workbooks.Open Filename:="C:\Users\Dell\Desktop\Acoustic Files\Web Booking Macro\Testing Invoice List.xlsx" Worksheets("Invoices").Activate Range("A2").Select Rows("2:2").Select Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False ActiveWorkbook.Save ActiveWindow.Close End Sub
try deleting it. your next line is another "select" so it does nothing anyway
Regards, Warship
Excel 2007 on XP
We learn by teaching... Please complete the learning curve with feedback.
Frustration is due to lack of knowledge. Lack of knowledge is due to frustration. Relax.
Quandary: How is it that the Calendar is moving so fast when the Clock is moving so slow?
ALWAYS USE A COPY OF YOUR FILE WHEN TESTING CODE.
Try without selecting:
Sub Invoice_List()
'
' Invoice_List Macro
Range("A26:G26").Copy
Workbooks.Open Filename:="C:\Users\Dell\Desktop\Acoustic Files\Web Booking Macro\Testing Invoice List.xlsx"
With Worksheets("Invoices").Rows("2:2")
.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
.PasteSpecial Paste:=xlPasteValues
End With
ActiveWorkbook.Close True
End Sub
HTH,
Smitty
Every once in a while, there's a sudden gust of gravity...
Check out my new book at the Mr. Excel Bookstore!
Mr. Excel HTML Maker - Post a shot of your sheet
In response to Warship: Ive tried that but then it highlights Rows(2:2).Select with an same error.
Last edited by lomax; Nov 11th, 2012 at 11:49 AM.
Wow Smitty, nice one, thanks!
Bookmarks