running a macro within anohter macro in Excel

  • Thread starter Thread starter Pat
  • Start date Start date
P

Pat

I have 2 macros written. I would like to
press Alt G for example and have it run
Alt F followed by additonal instructions.
Both macros work fine independently, but
I want to execute both with the button I
have set up for one.

Thanks!!
 
One way:

Public Sub Macro1()
'Alt-F
MsgBox "Macro1"
End Sub

Public Sub Macro2()
MsgBox "Macro2"
End Sub

Public Sub Macro3()
'Alt-G
Macro1
Macro2
End Sub

or, if you're never going to run Macro2 independently, just:

Public Sub Macro2()
'Alt-G
Macro1
MsgBox "Macro2"
End Sub
 
You can also try calling a subroutine in JEM's example

Call Macro1
Call Macro2

-Neil
 
Call is implied, in this case:

Public Sub Macro1()
Macro2
End Sub

and

Public Sub Macro1()
Call Macro2
End Sub

are functionally identical.
 
Back
Top