Looping Macro Advice Please

StewartS

Board Regular
Joined
Feb 24, 2002
Messages
217
Hi

I have a number of macros which use the same loop data to change 300 individual workbooks but perform different activities within the loop, such as updating actual and budget data, resetting workbooks from read only to write, updating the module in the workbooks etc.

I have a menu sheet with buttons on which are used to run these macros as required. What I was wondering is how I could reduce the amount of code by possibly allowing the main loop macro to select and run the appropriate macro within the loop.

As an example selecting button 1 would select the loop macro and choose to run macro 1 in it whilst similarly button 2 would run macro 2 etc. I'm Ok with calling the macro within the loop it is just how to select it that I'm unsure of.

Any suggestions would be welcome.

Thanks

StewartS
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
You can run one macro from inside another macro by using the "Call" function. Example

Code:
For i = 1 To 20
Call Macroname
Next
 
Upvote 0
Thanks

These were the sort of things I was thinking of, just good to get some confirmation.

StewartS
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,535
Members
449,037
Latest member
tmmotairi

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