View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
tigoda tigoda is offline
external usenet poster
 
Posts: 26
Default exiting the whole macro

same to you tom, thanks

"Tom Ogilvy" wrote:

The END command by itself halts code execution. However, it doesn't do it
nicely.

(see help).

To do it nicely, you will need to put your error handling only in the
topmost routine and vba will seek the first error handler going back up the
call chain ending up in the topmost sub where you can exit.

--
Regards,
Tom Ogilvy


"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?