#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default exit sub

Is there a way to exit 2 subs if 1 has called the other. eg:

Sub 1
code......
code.....(if criteria met then)
Sub2
Code...
End sub

Sub 2
Code....
exit sub(this sub and sub1 if certain criteria not met)
else continue
code
end sub
I know I could set a variable to true or false, but was wondering if
there was a way to just exit all subs/macros.
Regards Robert

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default exit sub

The quick answer is no.

Another method:

You could have an error handler in only the topmost sub and raise an error
in the lowest sub.

another is to make the second sub a function and react to the returned value
(similar to what you spoke of).

--
Regards,
Tom Ogilvy



"RobcPettit" wrote:

Is there a way to exit 2 subs if 1 has called the other. eg:

Sub 1
code......
code.....(if criteria met then)
Sub2
Code...
End sub

Sub 2
Code....
exit sub(this sub and sub1 if certain criteria not met)
else continue
code
end sub
I know I could set a variable to true or false, but was wondering if
there was a way to just exit all subs/macros.
Regards Robert


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 129
Default exit sub

What about:

If Condition Then
Exit Sub
End If

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default exit sub

Thanks for both your replys. Thats what I was thinking, thanks for the
confirmation.
Regards Robert

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
If Then Else with Exit For [email protected] Excel Programming 9 December 21st 05 04:27 PM
how to exit sub xiang Excel Programming 3 December 9th 05 05:46 AM
exit while? Steven Deng Excel Programming 1 November 6th 04 12:14 AM
If a called sub exit, how to the caller exit right away? luvgreen[_4_] Excel Programming 4 February 24th 04 05:06 PM
Exit Sub? Eva Shanley[_2_] Excel Programming 3 December 24th 03 02:15 PM


All times are GMT +1. The time now is 09:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"