Exit Sub

  • Thread starter Thread starter Raman325
  • Start date Start date
R

Raman325

I have a subroutine which calls another subroutine. The child subroutine
has an error mechanism that displays a message and then is supposed to
exit out of the subroutine. Exit Sub only works for the child
subroutine, however, and the main subroutine which called the child
subroutine still runs. Is there a call or command to exit out of
everything? Thanks in advance.
 
You can use the End statement. Be aware that it clears all variables as
well as ending code execution.

--
Jim
message |
| I have a subroutine which calls another subroutine. The child subroutine
| has an error mechanism that displays a message and then is supposed to
| exit out of the subroutine. Exit Sub only works for the child
| subroutine, however, and the main subroutine which called the child
| subroutine still runs. Is there a call or command to exit out of
| everything? Thanks in advance.
|
|
| --
| Raman325
| ------------------------------------------------------------------------
| Raman325's Profile:
http://www.excelforum.com/member.php?action=getinfo&userid=24748
| View this thread: http://www.excelforum.com/showthread.php?threadid=544854
|
 
A couple of common techniques are:

1. Use a global boolean variable and set that in each subroutine. Then you can
examine that to see if you should quit or continue.

2. Another way would be to change your child subroutines to functions. Let
them return a boolean variable that you can check.
 
Back
Top