View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.word.vba.beginners
Ardus Petus Ardus Petus is offline
external usenet poster
 
Posts: 718
Default Beginners question: how to stop / abort execution of vba program

Use the End instruction
Just End, not End Sub or End Function

HTH
--
AP

"Rainer" a écrit dans le message de news:
...
Hi,

how can I abort / cancel a vba program immediately, without returning to
the calling procedure?
I already have a rather complex vba application with many sub's and
functions.
The only thing I found by now is the "stop" command, but it enters
debugging mode, so this is not what I want.
i want to have something like this:

Sub Main
CheckValues
MsgBox "Completed successfully"
End Sub

Sub CheckValues
If SomeVar = SomeValue Then
MsgBox "Error"
'now stop it
End If
End Sub