embedding a macro in an anotger one

H

Hélène

Hi all
does anyone know how to call a macro from another macro. I wante to call
macro2 within macro1.
Thanks for your help
 
R

Rod Gill

Hi,

Macro2

is all you need to do, or:

Macro2 paramater1, paramater2

if you have paramaters.

If Macro2 is in another project file, you will first need to set a reference
to it (In VBE select Tools, References).

--
Rod Gill
Project MVP
For Microsoft Project companion projects, best practices and Project VBA
development services
visit www.projectlearning.com/
 
D

David Stumbles

G'day,

This is simply a case of typing the name of the macro that
you want to call into the name of the one you are calling
it from. Using the names you have given, it would look
like this:

Sub macro1()
macro2
End Sub

Often it is an advantage to have a main macro and to call
all others from it, like this:

Sub MainMacro()
macro1
macro3
macro4
End Sub

Sub macro1()
macro2
End Sub

The code will continue from the line following the one
where the macro is called once the called macro is
finished.

I hope this helps.

Dave.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top