ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Exit All Sub Command? (https://www.excelbanter.com/excel-programming/391418-exit-all-sub-command.html)

jutlaux

Exit All Sub Command?
 
I have a sub routine called "Main" that calls routine "FindIt". Within
"Findit" I have some I am looking for arouse things. If I don't find it I
want to exit out not just "Findit", but also "Main". Is there an simple way
(one command) to do this besides setting a flag in "Findit" and checking it
in "Main"?

Jim Cone

Exit All Sub Command?
 

You could change FindIt to a function and read the return
value from the function.
The other much less desirable method is to place the single
word "End" in your code when you want to shut everything down.
Be sure to read the help file on the End statement before using it.
'---
Sub Main()
'do stuff
If FindIt() Then Exit Sub
'do more stuff
End Sub
'---
Function FindIt() As Boolean
Dim strWord As String
'do stuff
FindIt = Len(strWord) = 0
End Function
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"jutlaux"
wrote in message
I have a sub routine called "Main" that calls routine "FindIt". Within
"Findit" I have some I am looking for arouse things. If I don't find it I
want to exit out not just "Findit", but also "Main". Is there an simple way
(one command) to do this besides setting a flag in "Findit" and checking it
in "Main"?


All times are GMT +1. The time now is 05:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com