View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default stop calling sub Intentionally without error.

Instead of performing the "less than 50" test in sub_2, why not do it in
sub_1?

Sub sub_1()
If Range("somerange").Rows.Count < 50 Then
MsgBox "Less than 50 rows!"
Exit Sub
End If
Call sub_2
' do some stuff
End Sub

Sub sub_2()
' do some stuff
End Sub

--
Rick (MVP - Excel)


"BRC" wrote in message
...
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