workbooks.open: select method of range class failed

lomax

Board Regular
Joined
Nov 9, 2011
Messages
67
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
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
try deleting it. your next line is another "select" so it does nothing anyway
 
Upvote 0
Try without selecting:

<font face=Calibri><SPAN style="color:#00007F">Sub</SPAN> Invoice_List()<br><SPAN style="color:#007F00">'</SPAN><br><SPAN style="color:#007F00">' Invoice_List Macro</SPAN><br><br>    Range("A26:G26").Copy<br>    <br>    Workbooks.Open Filename:="C:\Users\Dell\Desktop\Acoustic Files\Web Booking Macro\Testing Invoice List.xlsx"<br>   <br>        <SPAN style="color:#00007F">With</SPAN> Worksheets("Invoices").Rows("2:2")<br>            .Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove<br>            .PasteSpecial Paste:=xlPasteValues<br>        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>    <br>    ActiveWorkbook.Close <SPAN style="color:#00007F">True</SPAN><br>    <br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

HTH,
 
Upvote 0
In response to Warship: Ive tried that but then it highlights Rows(2:2).Select with an same error.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,517
Messages
6,114,089
Members
448,548
Latest member
harryls

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top