Kind of new to macros and VBA, but I'm starting to get the hang of it. I'm currently using Excel 2007.
My document has one module, and the main sub runs three other subs. i.e.:
Sub Master()
MiniSub1
MiniSub2
MiniSub3
End Sub
In the sub I'm calling MiniSub1, I have a MsgBox which I'm using vbOKCancel. With that, I have:
Dim ErrorMessage As String
ErrorMessage = MsgBox("You messed up",vbOKCancel)
If ErrorMessage = vbOK Then
***(some code here)***
Else
Exit Sub
End If
***(followed by a lot more code)***
The Exit Sub and the code as a whole work great, but I'd like it to exit the entire sub (Master); just stop everything there and end the macro. Instead, after clicking "cancel" the macro proceeds to MiniSub2.
This is intended to be similar to an error message, where clicking "Ok" lets you continue, while clicking "Cancel" lets you stop everything to fix the error before running it again.
I'd expect it'd be some code inserted in Sub Master(), but I have no idea what to do.
Is this possible? And if so, thanks for your help!
Eric
My document has one module, and the main sub runs three other subs. i.e.:
Sub Master()
MiniSub1
MiniSub2
MiniSub3
End Sub
In the sub I'm calling MiniSub1, I have a MsgBox which I'm using vbOKCancel. With that, I have:
Dim ErrorMessage As String
ErrorMessage = MsgBox("You messed up",vbOKCancel)
If ErrorMessage = vbOK Then
***(some code here)***
Else
Exit Sub
End If
***(followed by a lot more code)***
The Exit Sub and the code as a whole work great, but I'd like it to exit the entire sub (Master); just stop everything there and end the macro. Instead, after clicking "cancel" the macro proceeds to MiniSub2.
This is intended to be similar to an error message, where clicking "Ok" lets you continue, while clicking "Cancel" lets you stop everything to fix the error before running it again.
I'd expect it'd be some code inserted in Sub Master(), but I have no idea what to do.
Is this possible? And if so, thanks for your help!
Eric