Thread: Kill Macro
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Otto Moehrbach Otto Moehrbach is offline
external usenet poster
 
Posts: 1,090
Default Kill Macro

Jeff
For instance, let's say you have a macro like this:
Sub Macro
Call Macro2
Call Macro3
End Sub
And you want to place your IF statement in Macro2 and stop all code if True.
Do something like this:
Dim CancelA As Boolean
Sub Macro
CancelA = False
Call Macro2
If CancelA = True Then Exit Sub
Call Macro3
End Sub
Within Macro2 you would have:
If (Statement = True) Then
CancelA = True
Exit Sub
End If
HTH Otto
"Jeff" wrote in message
...
Hi,

I am running a macro and want to put in an option where the program stops
under certain conditions

IF (statement=true) then stop the macro

I was using "Exit Sub" but this just kicks it out of the sub(), not the
entire macro. Is there a way to end the entire macro?

Thanks for your help!