View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Stopping a 'multi-level' procedure

Put the error handler only in the initial/toplevel routine. If an error
occurs, vba moves up the stack until it finds an error handler in one of the
calling routines. If it finds none, then it errors, otherwise the first
error handler it finds will handle the error. So you could end at that
point (in the top level routine).

--
Regards,
Tom Ogilvy

"Neal Zimm" wrote in message
...
I have some longer macros that have the structu
sub toplevel()
call nextlevel 'or call nextlevel1(a,b,c)
'and in the nextlevel code
call lower_level 'or call lower_level2(d,e,f)

In many of the lower_level procedures there is error checking where 'exit
sub' is used to stop execution. It's getting tiresome to code all of the
'back track' conditions in order to stop the execution of the toplevel

sub.

Is there an Excel vba way of immediately stopping the top most sub when a
lower level sub contains an error?

Thanks,
--
Neal Z