Assign group of worksheets to array and for loops.

dr_damo

New Member
Joined
Oct 8, 2010
Messages
39
Hi.
I've got the concept of what I want to do in my head, but making it happen isn't working...




I have a sheet with records from 45 different places. Each place could have anywhere from 1 to 1000 records associated with it.


e.g.


Building A10000 has 45 records


Building A20000 has 900 records


(Building name is always a letter followed by 5 numbers. i.e. A10000 or Z99999)


I have a data sheet and 16 individual pivot sheets.


I have managed to split the data sheet by building name. (using code off of here)


I would like to select the separate building sheet plus the 16 individual pivot sheets and move these to a new workbook, which gets saved at location path name.


That will be sheets A1 + 16 to A45 + 16 as new workbooks in a new location.


I thought it would be something like



For each ws in wb with name like "******"
select ws and array
save as new work book with path

I'm looking around trying to cobble things together and getting nowhere.
Any help on this would be great.
I have zero code to do this.

I think there are a number of elements I'm after help and advice on:

1) I can define a group of worksheets as an array, but can I select this array plus a ws with a name like and then copy to a new work book?
2) How does the "choose sheet name with name like" functionality work? I would guess that "Y00000" and "Y00001" are all "******". How do i say "letter at position 1, 0-9 at positions 2-6"?
2) how can I then loop through all ws with name like "Y0000", selecting that sheet plus the array and saving to a new workbook at location with name like the individual sheet name ("Y00000")?
4) The pivot tables in the array will be based on the original (all data) table. When the pivots are selected and moved with the individual sheet, they will have to be updated to look at the data in the individual sheet. I have a macro to update all the pivots separately. Can the pivots be updated in the copy and create new workbook procedure?


I appreciate this may be fairly simple but also fairly complicated to explain / provide advice on and am grateful for any response.

thanks!
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Forum statistics

Threads
1,215,343
Messages
6,124,405
Members
449,157
Latest member
mytux

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