MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Call 1 Macro from Another


Posted by Simon McArdle on May 17, 2001 5:12 AM

Hi,

How can I call one macro from another macro.

Thanks
Simon


Posted by Chris Wheeler on May 17, 2001 5:46 AM

You Start Recording A New Macro, While You're Recording The New Macro Play The Old One.

Posted by Simon McArdle on May 17, 2001 6:09 AM

The Macro I want to call is one of 6 macros that all do the same thing but with different data. The main macro will be used to call any of the six. I do not know how you can do this by recording a new macro to call one of the six. This will mean I have to create 6 new macros and I may as well just stick with the six ive already got. The reason I wanted one macro to call any of six is that the one macro would have changes made to it should they be required rather than having to make the same change to six individual macros.

Thanks for your help.

Simon

Posted by Wes Barber on May 17, 2001 7:58 AM

If you know how to go into "edit" in the main macro, you can simply create an if statement with your criteria and use the statement "call [name of macro to be called]" each time you want a particular macro to be called.

if x=0
call macro 1
else if x=1
call macro 2
else
call macro 3
endif

Hope this helps...