How-To Run Multiple Macro's One After The Other

GreenWizard

Board Regular
Joined
Dec 8, 2013
Messages
106
I have 4 macro's. The first macro format's data. The second macro saves the .xlsx with a unique name. The third macro merges data from other excel files. And the fourth macro saves the merged data as another .xlsx.

Is there any way to run all the macro's at once and in order? If I group all the code together I have issues, because excel tries to save things before data can be merged or formatted.

Much Appreciated!!!!
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
You could use a 'master' macro which launches the other 4 in order. You will need to include the correct macro names.
Code:
Sub RunFour()
'change macro names to suit
Call Macro1
Call Macro2
Call Macro3
Call Macro4
End Sub
 
Upvote 0
If they are regular subs and not Workbook or Worksheet subs then create another macro and call the other macro's i.e. if you had macro's called Mac1 and Mac2 then you would do something like

Code:
Sub NewMac()
Call Mac1
Call Mac2
End Sub

or even

Code:
Sub NewMac()
Mac1
Mac2
End Sub
 
Upvote 0
Is this still possible? I am desperately trying to get subs to run in a particular order and it does not.

VBA Code:
Sub PriceRefresh_Master()
    PriceRefresh__1_ClearC12
    PriceRefresh_1a_PHP
    PriceRefresh_1b_XRP
    PriceRefresh_1c_XLM
    PriceRefresh_1d_BTC
    PriceRefresh__1_CopyC13_PasteC12
End Sub

I don't know if I'm using a regular sub or workbook or worksheet subs.
 
Upvote 0
Is this still possible? I am desperately trying to get subs to run in a particular order and it does not.

VBA Code:
Sub PriceRefresh_Master()
    PriceRefresh__1_ClearC12
    PriceRefresh_1a_PHP
    PriceRefresh_1b_XRP
    PriceRefresh_1c_XLM
    PriceRefresh_1d_BTC
    PriceRefresh__1_CopyC13_PasteC12
End Sub

I don't know if I'm using a regular sub or workbook or worksheet subs.

The very last sub (PriceRefresh__1_CopyC13_PasteC12) takes the values a formula calculates in cell C13 and pastes the values in C12, the issue is that it does not wait for the other subs to complete therefore the values that are pasted into cell C12 are incorrect.
 

Attachments

  • 2020-04-28 16_03_21-Moon Ride 2020.xlsm - Excel.png
    2020-04-28 16_03_21-Moon Ride 2020.xlsm - Excel.png
    18.8 KB · Views: 56
Upvote 0
can we run the 2 macro from a button press ?
with this :
Sub NewMac()
Call Mac1
Call Mac2
End Sub

Thanks
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,191
Members
452,616
Latest member
intern444

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