Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Exit Sub should work.
Sub test() call Test_2 MsgBox ("fail") End Sub Sub Test_2() If myCriteria = True Then Exit Sub End If 'the code I need has to go here! End Sub I threw in an If statement to show that you can set the criteria for when you want to exit the Test_2 sub. The Exit Sub in Test_2 will automatically revert back to the calling sub Test_1. It will begin executing on the line following the call for Test_2, or in this case, your message box. "tigoda" wrote: I have the following example: Sub test() call Test_2 MsgBox ("fail") End Sub Sub Test_2() 'the code I need has to go here! End Sub in the second sub I need a command/section of code that will exit the whole macro, currently end sub and exit sub just exit the second sub and continue running the first sub (displaying the msg box "fail" as a test) there has to be a way to safety bomb out of the macro without resorting to ending and closing the whole sheet, can anyone help? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro not exiting correctly | Excel Programming | |||
Help with Exiting Sub if Value is Not Found | Excel Programming | |||
Exiting a Textbox | Excel Programming | |||
Macro suffers from premature exiting | Excel Programming | |||
Exiting a VBA Macro by user intervention | Excel Programming |