Thread: exit sub
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
mike allen[_2_] mike allen[_2_] is offline
external usenet poster
 
Posts: 85
Default exit sub

my placements are as i want them. to clarify: i am simply running sub1,
which does certain things, then calls sub2. now in sub2, certain things are
done, then IF something happens (1=1 in this case), i want to exit
everything. exiting sub2 is easy, but i don't want it going back and
finishing sub1 (after "call sub2"), which is what it does in this example.
this may help:
sub1()
'various code is written here
call sub2
'more various code is written here, but do not want to go this far unless
sub2 is completed
end sub

sub2()
'various code is written here
if 2=2 then
exit sub 'this is where i need to exit not only sub2, but sub1 as well
endif
'more various code is written here
end sub

thanks, mike allen

"Frank Stone" wrote in message
...
your example is a bit confusing. but if code stops before
a call, the call is never made. move your call to the end
of sub1(or at least after the exit sub command.) Some
where you will have to add a exit sub command in sub1 to
stop it from call sub2. now...where to put the exit sub
command. you didn't provide enought information to answer
that.
-----Original Message-----
how do i get out of all subs upon a certain event?

sub1()
call sub2
'more code here--i do not want sub1 to get this far

unless sub2 runs all the
way through
end sub

sub2()
if 1=1 then
exit sub 'i want this to quit sub1 as well as sub2
end if
end sub

there may be more embedded subs, so i don't think i can

specify which sub to
exit (if that is even possible).
thanks, mike allen


.