VBA - assign WB to new variable, save and close but keep previous variable open.

RCBricker

Well-known Member
Joined
Feb 4, 2003
Messages
1,560
This is/was hard to put into words for a title and as such a search.

I have never needed to do this, but now I do so need some guidance.

I have a workbook that I am assigning to a variable. What I want to do is use that workbook like a template. I have to make 48 similar workbooks, but really only want the code to work once, then adjust based on the workbook it is currently on.

wbA has code that sets up all the various sheets, pulls in the data and organizes everything.

wbA is then saved as a new variable- lets say wbB, code then runs and makes adjustments to the various sheets including removing unwanted data. Save close.

Back to wbA rinse and repeat till down.

I am uncertain as to how to assign another variable to the existing workbook, save it and close it and yet still have the original workbook still open without the changes....

I am certain that I am missing something simple but anything you all can offer that will at least point me in the correct direction would be great.

thanks,
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Are you actually creating new workbook at some point?

If you aren't then you can't do what you want.
 
Upvote 0
yes wbB is supposed to be a new workbook. But I think the way I am thinking about it then I am not actually creating a new object.
 
Upvote 0
Can you post what you have so far?

By the way, have you considered actually using a template?
 
Upvote 0

Forum statistics

Threads
1,224,846
Messages
6,181,307
Members
453,031
Latest member
Chris_1

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