View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default stop calling sub Intentionally without error.

You should write your Sub_2 as a Function procedure that returns True
if execution is to continue or False if execution should cease. E.g.,


Function Proc2()
If Range("SomeRange").Rows.Count < 50 Then
Proc2 = False
Else
Proc2 = True
End If
End Function

Then, in Sub_1,

Sub Sub_1()
Dim Continue As Boolean
Continue = Proc2()
If Continue = False Then
Exit Sub
End If
' more code
End Sub

Cordially,
Chip Pearson
Microsoft MVP 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
[email on web site]





On Tue, 12 Jan 2010 10:43:24 -0800 (PST), BRC
wrote:

Hi all,
I am trying to find a way to stop all sub's from running if certain
conditions are encountered. sin the example below, if row count is
less than 50 I would like to stop sub_1 from running. All of the
posts i find on this subject are related to errors. this isn't really
an error just a condition. Thanks for any advice. BRC

sub _1()
call sub_2
do some stuff
end sub

sub_2()
if range ("somerange").rows.count <50 then
msgbox("Less than 50 rows")
exit sub
else
end sub