running macros back to back

cazdealer

Board Regular
Joined
Mar 12, 2011
Messages
96
Hi,
I am going away this weekend for 3 days.
I have 4 differents workbooks that I would like to run a macro in each of them. Its takes about 10-12 hours for the macro to be done (it involves using the solver... that's why it's long).




anyways my question is what would be the simplest way make to do this:

open workbook back1.xlsm
run macro Start1
when macro is finished, save the workbook
close it

open workbook back2.xlsm
run macro Start2
when macro is finished, save the workbook
close it

open workbook back3.xlsm
run macro Start3
when macro is finished, save the workbook
close it

open workbook back4.xlsm
run macro Start4
when macro is finished, save the workbook
close it




for the moment, my macros Start1,2,3,4 are located in respectively every module1 of the four workbooks (back1,2,3,4).

thanks
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Try like this

Code:
Workbooks.Open Filename:="back1.xlsm"
Call Start1
Workbooks("back1.xlsm").Close savechanges:=True

There is something wrong if they are taking that long and you are not trying to calculate pi to a zillion decimal places.
 
Upvote 0
thanks for your help Peter...

few more questions:

1.
when I write
Workbooks.Open Filename:="back1.xlsm"
where does the file needs to be located for the macro to open it (there is no path... I dont understand I can can open the file)

2.
when it says "call Start1", does it knows it's from back1.xlsm?

3.
can I just create a new workbook with this macro in it and then run it:
Code:
Workbooks.Open Filename:="back1.xlsm"
Call Start1
Workbooks("back1.xlsm").Close savechanges:=True

Workbooks.Open Filename:="back2.xlsm"
 Call Start2
 Workbooks("back2.xlsm").Close savechanges:=True

Workbooks.Open Filename:="back3.xlsm"
 Call Start3
 Workbooks("back3.xlsm").Close savechanges:=True

Workbooks.Open Filename:="back4.xlsm"
  Call Start4
  Workbooks("back4.xlsm").Close savechanges:=True

also, concerning the long time for my macro, it's because there is a loop that use the solver 2000 times with a 60 seconds without improvement option in it.
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,626
Members
452,933
Latest member
patv

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