Aborting a Sub procedure from a UserForm
I declare a Public Boolean variable in the Declaration section of the
module containing the Sub Procedure eg Public binAbortSub as Boolean.
In the Sub make it equal False before showing the UserForm (binAbortSub
= False). In the code section of the Cancel button type
BinAbortSub = True
Unload Userform (Use your UserForm's Name here)
In the Sub, straight after the line with UserForm.Show, type
If binAbortSub = True then
exit Sub
End If
This works for me but I'm no expert. There might be a better way.
|