Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copy Worksheets to New Book
I recoreded a macro and it worked fine, I then copied the coed into a
function and it fails here is the code ActiveWorkbook.Sheets(Array("Airgas", "Praxair", "Other G1 Cust", "T1 Cust", "Other Cust")).Select ActiveWorkbook.Sheets("Other Cust").Activate ActiveWorkbook.Sheets(Array("Airgas", "Praxair", "Other G1 Cust", "T1 Cust", "Other Cust")).Copy Befo=Workbooks(NEWWORKSHEET).Sheets(11) application.Run Range("ScOnWindow") ActiveWorkbook.Sheets(Array("Airgas", "Praxair", "Other G1 Cust", "T1 Cust", "Other Cust")).Select ActiveWorkbook.Sheets("Airgas").Activate Range("A1").Select ActiveWorkbook.Sheets("Price SRP1 by Req Date").Select it fails on this line ActiveWorkbook.Sheets(Array("Airgas", "Praxair", "Other G1 Cust", "T1 Cust", "Other Cust")).Copy Befo=Workbooks(NEWWORKSHEET).Sheets(11) with the error message subscript out of range. (NEWWORKSHEET is the name of the book the sheets are being copied to and is declared earlier in the code) Any solutions would be helpful thanks in advance |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copy Worksheets to New Book
you're trying to copy before sheet 11. Are ther 11 sheets in the target
workbook already? maybe replace Befo=Workbooks(NEWWORKSHEET).Sheets(11) with Befo=Workbooks(NEWWORKSHEET).Sheets( Workbooks(NEWWORKSHEET).worksheets.count) "Nigel" wrote: I recoreded a macro and it worked fine, I then copied the coed into a function and it fails here is the code ActiveWorkbook.Sheets(Array("Airgas", "Praxair", "Other G1 Cust", "T1 Cust", "Other Cust")).Select ActiveWorkbook.Sheets("Other Cust").Activate ActiveWorkbook.Sheets(Array("Airgas", "Praxair", "Other G1 Cust", "T1 Cust", "Other Cust")).Copy Befo=Workbooks(NEWWORKSHEET).Sheets(11) application.Run Range("ScOnWindow") ActiveWorkbook.Sheets(Array("Airgas", "Praxair", "Other G1 Cust", "T1 Cust", "Other Cust")).Select ActiveWorkbook.Sheets("Airgas").Activate Range("A1").Select ActiveWorkbook.Sheets("Price SRP1 by Req Date").Select it fails on this line ActiveWorkbook.Sheets(Array("Airgas", "Praxair", "Other G1 Cust", "T1 Cust", "Other Cust")).Copy Befo=Workbooks(NEWWORKSHEET).Sheets(11) with the error message subscript out of range. (NEWWORKSHEET is the name of the book the sheets are being copied to and is declared earlier in the code) Any solutions would be helpful thanks in advance |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Moving worksheets to another book - 2nd book will not appear | Excel Discussion (Misc queries) | |||
copy worksheets to new book without linking to original book | Excel Discussion (Misc queries) | |||
How many worksheets in a book? | Excel Discussion (Misc queries) | |||
Copy worksheets from one book to another | Excel Programming | |||
Copy Worksheets from one book to another? | Excel Programming |