Looping and saving Macro

ftsang

New Member
Joined
Jun 9, 2005
Messages
25
Hi guys,

Is there a macro that I can use which, given a list of numbers (in a sheet called Variables.xls), and an empty report shell (Shell.xls), will:

1) Run a macro (within Shell.xls) based on the first number in Variables.xls
2) Save the output as 'number'.xls, where 'number' is the number in the list
3) Close 'number'.xls and re-open the report shell
4) Pick the next number in the list

etc, until the last number is used.

Sounds complicated, but should be easy for you guys! The main bit I am having problems with is the looping and saving.....

Thanks!
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
I think that the problem you will have with this is that you are closing the file on which you have the macro running. You could either create a separate file to hold the macro or put the macro on the Variables file instead. Otherwise, if you were not too concerned about the macro being on all the copies, get "Number" from the Variables file and in Shell SAVE AS the new name, get the next number and SAVE AS again but this time you will be saving 1.xls (for example) as 2.xls. AT the end of this, you can close the final file.
 
Upvote 0

Forum statistics

Threads
1,203,607
Messages
6,056,285
Members
444,855
Latest member
archadiel

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