Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
if I have many sub like this: Sub macro1() .... macro2 (calling macro2) .... End sub() Sub macro2() .... exit-quit ??? .... End sub() And in macro2 I need quit-exit all subs, not only macro2 (like Exit sub can do it), can you help me? tom |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You can use the End statement to terminate all running VBA code.
Note that this will reset all global variables to their default values. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Tom" wrote in message ... Hello, if I have many sub like this: Sub macro1() .... macro2 (calling macro2) .... End sub() Sub macro2() .... exit-quit ??? .... End sub() And in macro2 I need quit-exit all subs, not only macro2 (like Exit sub can do it), can you help me? tom |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Another couple of ways:
'a nice module level boolean variable Dim OkToContinue as boolean sub macro1() call macro2 if oktocontinue =false then exit sub end if end sub sub macro2 'do stuff if something = true then oktocontinue = false else oktocontinue = true end if end sub Or you can convert your subroutines to functions and return a boolean value. sub macro1 if func2 = false then exit sub end if end sub function func2 as boolean 'do stuff if something = true then func2 = false else func2 = true end if end function Tom wrote: Hello, if I have many sub like this: Sub macro1() .... macro2 (calling macro2) .... End sub() Sub macro2() .... exit-quit ??? .... End sub() And in macro2 I need quit-exit all subs, not only macro2 (like Exit sub can do it), can you help me? tom -- Dave Peterson |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I think you could turn macro2 into a function that returns either false or
true. You can let it true if you want to exit immediately. The exit is of course done from macro1. If you get false, proceed in macro1 /Fredrik "Tom" wrote in message ... Hello, if I have many sub like this: Sub macro1() .... macro2 (calling macro2) .... End sub() Sub macro2() .... exit-quit ??? .... End sub() And in macro2 I need quit-exit all subs, not only macro2 (like Exit sub can do it), can you help me? tom |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel won't quit | Excel Discussion (Misc queries) | |||
Excel Won't Quit | Excel Programming | |||
Another Quit problem | Excel Programming | |||
If a called sub exit, how to the caller exit right away? | Excel Programming | |||
Excel won't quit | Excel Programming |