ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run a macro within a macro (https://www.excelbanter.com/excel-programming/355897-run-macro-within-macro.html)

norrislaketn

Run a macro within a macro
 
How can you execute a macro within another macro.

Example: Run macro a in macro b. Cutting and pasting does not seem to work.



Jim Thomlinson

Run a macro within a macro
 
Something like this..

Sub Macro1()
msgbox "macro1"
call Macro2
exit sub

Sub Macro2()
msgbox "macro2"
exit sub


--
HTH...

Jim Thomlinson


"norrislaketn" wrote:

How can you execute a macro within another macro.

Example: Run macro a in macro b. Cutting and pasting does not seem to work.



Gary''s Student

Run a macro within a macro
 
Sub hello()
Call boxit
End Sub

Sub boxit()
MsgBox ("in boxit")
End Sub
--
Gary's Student


"norrislaketn" wrote:

How can you execute a macro within another macro.

Example: Run macro a in macro b. Cutting and pasting does not seem to work.



Trevor Shuttleworth

Run a macro within a macro
 
Sub Macro1()
Msgbox "Macro1"
' some code
Macro2
End Sub

Sub Macro2()
Msgbox "Macro2"
' some code
Macro3
Macro4
End Sub

Sub Macro3()
Msgbox "Macro3"
' some code
End Sub

Sub Macro4()
Msgbox "Macro4"
' some code
End Sub

Regards

Trevor


"norrislaketn" wrote in message
...
How can you execute a macro within another macro.

Example: Run macro a in macro b. Cutting and pasting does not seem to
work.





norrislaketn

Run a macro within a macro
 
Thanks for the info. Your solution will run if I step into it. If I run ir
directly from the macro shortcut key it does not run. It acts as if it is
executing the next command before the call is complete. Any other thoughts?

"Gary''s Student" wrote:

Sub hello()
Call boxit
End Sub

Sub boxit()
MsgBox ("in boxit")
End Sub
--
Gary's Student


"norrislaketn" wrote:

How can you execute a macro within another macro.

Example: Run macro a in macro b. Cutting and pasting does not seem to work.



norrislaketn

Run a macro within a macro
 
Thanks for the info. Your solution will run if I step into it. If I run ir
directly from the macro shortcut key it does not run. It acts as if it is
executing the next command before the call is complete. Any other thoughts?


"Trevor Shuttleworth" wrote:

Sub Macro1()
Msgbox "Macro1"
' some code
Macro2
End Sub

Sub Macro2()
Msgbox "Macro2"
' some code
Macro3
Macro4
End Sub

Sub Macro3()
Msgbox "Macro3"
' some code
End Sub

Sub Macro4()
Msgbox "Macro4"
' some code
End Sub

Regards

Trevor


"norrislaketn" wrote in message
...
How can you execute a macro within another macro.

Example: Run macro a in macro b. Cutting and pasting does not seem to
work.






norrislaketn

Run a macro within a macro
 

Thanks for the info. Your solution will run if I step into it. If I run ir
directly from the macro shortcut key it does not run. It acts as if it is
executing the next command before the call is complete. Any other thoughts?

"Jim Thomlinson" wrote:

Something like this..

Sub Macro1()
msgbox "macro1"
call Macro2
exit sub

Sub Macro2()
msgbox "macro2"
exit sub


--
HTH...

Jim Thomlinson


"norrislaketn" wrote:

How can you execute a macro within another macro.

Example: Run macro a in macro b. Cutting and pasting does not seem to work.




All times are GMT +1. The time now is 07:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com