Stop a procedure call if..

mantis_sg

Board Regular
Joined
Nov 16, 2005
Messages
126
Hi is there a way to end all procedures or to skip/stop a procedure from running if an if statement is satisfied within another procedure... wow, not sure if I understand this...

was thinking of setting a global boolean and setting it to true in the if loop

but how would I code this and declare the variable, and how would I call it from within my main procedure? thanks.
 

Some videos you may like

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

BrianB

Well-known Member
Joined
Feb 17, 2003
Messages
8,127
A simple version. This stops the macro.
Code:
If x = 1 Then
    End
End If
 

mantis_sg

Board Regular
Joined
Nov 16, 2005
Messages
126
yeah, it's a little more complicated than that...

a button on a form does something like this....

Call a

If boolean = 1 then skip sub b
End if

Call b

End Sub

-----------------------------------------------------

Sub a

if something = true then
boolean = 1
Exis sub

End if

End Sub

--------------------------------------

Sub b

blah blah blah

End Sub
 

BrianB

Well-known Member
Joined
Feb 17, 2003
Messages
8,127
Need to change your logic. There is no code for "skip" - only various ways to select something to *do*. 'If' is one ..

The basic form is :-
Code:
If MyBoolean <> 1 Then
    b
Else       ' can be omitted
    ' do something else
End If
 

Watch MrExcel Video

Forum statistics

Threads
1,118,167
Messages
5,570,636
Members
412,334
Latest member
ExcelForLifeDontHate
Top