Archive of Mr Excel Message Board


Back to Excel VBA archive index
Back to archive home

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


Check out our Excel VBA Resources

Re: Call 1 Macro from Another

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.


Re: Call 1 Macro from Another

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


Re: Call 1 Macro from Another

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...



This archive is from the original message board at www.MrExcel.com.
All contents © 1998-2004 MrExcel.com.
Visit our online store to buy searchable CD's with thousands of VBA and Excel answers.
Microsoft Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.