![]() ![]() However, you will need the Call statement if your macro contains parameters (variables) that you want to pass through to the called macro or function. You can leave the word Call out, and just type in the macro name. 'When Macro2 is complete the code will continue 'to run below the call line in this macro 'Place code here to run AFTER Macro2 runs End SubĪnother thing to note is that you do not always have to use the Call statement to call another macro. 'Place code here to run before calling Macro2 'The following line will run Macro2 Call Macro2 Once it is complete, Macro1 will continue to run the next line of code under the Call statement. Once the Call line is hit, Macro2 will be run completely to the end. It's important to note that the two macros DO NOT run at the same time. The example below shows how to call Macro2 from Macro1. Just type the word Call then space, then type the name of the macro to be called (run). ![]() Here is an example of how to run another macro from a macro using the Call Statement. VBA Example: Run Another Macro from a Macro We can have several macros calling another macro. This helps us keeps our macros shorter and easier to manage. Did you know you can run other macros from a macro? This is a very efficient practice that allows us to reuse macros, so we don't have duplicate code snippets throughout our macros.
0 Comments
Leave a Reply. |