Exit Sub

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.
 
J

Jim Rech

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
|
 
D

Dave Peterson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top