ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Stop running a macro in the middle of a macro (https://www.excelbanter.com/excel-programming/331328-stop-running-macro-middle-macro.html)

gmunro

Stop running a macro in the middle of a macro
 
Hi,

I have a macro that runs another macro in it, something like this

Sub mymacro ()
code

Myothermacro

code

End sub
Sub Myothermacro()

Msgbox
If no then
Exit Sub
End if
End Sub


When I run the macro, if the answer is NO, it ends Myothermacro but
then resumes mymacro.

How can I have a messagebox in Myothermacro have a DEAD STOP and return
to sheet?

Any help is appreciated


Tom Ogilvy

Stop running a macro in the middle of a macro
 
Sub mymacro ()
code

If Myothermacro Then

code
End if

End sub


Function Myothermacro()

Msgbox
If no then
MyOtherMacro = False
else
MyOtherMacro = True
End if
End Function

--
Regards,
Tom Ogilvy



"gmunro" wrote in message
oups.com...
Hi,

I have a macro that runs another macro in it, something like this

Sub mymacro ()
code

Myothermacro

code

End sub
Sub Myothermacro()

Msgbox
If no then
Exit Sub
End if
End Sub


When I run the macro, if the answer is NO, it ends Myothermacro but
then resumes mymacro.

How can I have a messagebox in Myothermacro have a DEAD STOP and return
to sheet?

Any help is appreciated




Chris Ferguson

Stop running a macro in the middle of a macro
 
How about dim public StopFlag

set the stopflag in your second macro and test for it on return to your
first macro

Chris

"gmunro" wrote in message
oups.com...
Hi,

I have a macro that runs another macro in it, something like this

Sub mymacro ()
code

Myothermacro

code

End sub
Sub Myothermacro()

Msgbox
If no then
Exit Sub
End if
End Sub


When I run the macro, if the answer is NO, it ends Myothermacro but
then resumes mymacro.

How can I have a messagebox in Myothermacro have a DEAD STOP and return
to sheet?

Any help is appreciated




gmunro

Stop running a macro in the middle of a macro
 
Thank you



All times are GMT +1. The time now is 01:34 AM.

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