Problems copying selected worksheets to new workbook

RichardMGreen

Well-known Member
Joined
Feb 20, 2006
Messages
2,177
Hi all

I've run across a bit of a snag copying a list of worksheets to a new workbook.
This is the code I've currently got:-
Code:
'----- Add workbook ready for sheets to be copied -----
    Set wb = Workbooks.Add
'----- Copy relevant worksheets to new book -----
    Sheets(Array("Front_Page", "Stage_Of_Change", "Assessments_Taken", "Basic_8_Care_Plan_1", _
        "Basic_8_Care_Plan_2", "Basic_8_Care_Plan_3", "Basic_8_Care_Plan_4", "Basic_8_Care_Plan_5", _
        "Basic_8_Care_Plan_6", "Basic_8_Care_Plan_7", "Basic_8_Care_Plan_8", "Clinical_Data")).Copy After:=wb.Sheets(3)

When I run it, it creates the new workbook but then gives me a subscript out of range error when it tries to copy the sheets in the array.

Has anyone got any idea why?

I've confirmed all the sheet names are correct (copied/pasted from the sheet tabs).

If it helps I'm using 2003.
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Perhaps

Rich (BB code):
'----- Add workbook ready for sheets to be copied -----
    Set wb = Workbooks.Add
'----- Copy relevant worksheets to new book -----
    ThisWorkbook.Sheets(Array("Front_Page", "Stage_Of_Change", "Assessments_Taken", "Basic_8_Care_Plan_1", _
        "Basic_8_Care_Plan_2", "Basic_8_Care_Plan_3", "Basic_8_Care_Plan_4", "Basic_8_Care_Plan_5", _
        "Basic_8_Care_Plan_6", "Basic_8_Care_Plan_7", "Basic_8_Care_Plan_8", "Clinical_Data")).Copy After:=wb.Sheets(3)
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,558
Members
452,928
Latest member
101blockchains

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