I'm a freshman in college. We were assigned and excel project. We're recording macros and using VBA to edit them. All I need to know is how to make a sort of master macro to call on all the ones I have made at once. Help is much appreciated.
I'm a freshman in college. We were assigned and excel project. We're recording macros and using VBA to edit them. All I need to know is how to make a sort of master macro to call on all the ones I have made at once. Help is much appreciated.
Hello Mac3188,
Create a Sub procedure in a Standard VBA Module and list the macro you have already created in it. Calling this one macro will then execute all the macro inside of it one by one.
Example:
Be sure to include any arguments your macros use as well.![]()
Please Login or Register to view this content.
Sincerely,
Leith Ross
Thank you very much.
There are several options, with no "best answer".
One option is simply to list the names of each subroutine.
If any of the macros require that you pass arguments, simply list the arguments:![]()
Please Login or Register to view this content.
Another variation on this uses the VBA key word "Call":![]()
Please Login or Register to view this content.
All of that is fine as long as all macros (plus the "master") are in the same workbook, and the names of the "sub" macros never change. If either of these rules are violated, then you probably want to use the Excel "Run" method instead of the VB Call key word.![]()
Please Login or Register to view this content.
Note that since you are passing the names of the workbooks and the names of the macros as strings, you can replace the "fixed" strings with variables.![]()
Please Login or Register to view this content.
![]()
Please Login or Register to view this content.
Is it possible to call a Private Sub also? How?
Thanks,
Ricky
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks