Home |
Search |
Today's Posts |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Dear all, from the previous contributions on the "Exiting a macro" I conclude that it is impossible to leave a macro immediately in case of an error in a subroutine. Is this really true?? Please have a look at the following simple structure of a macro which is consisting of a large number of subroutines: '''''''''''''''''''''''''''''''''''''''''''''''''' Sub myMain() Call mySUB1 Call mySUB2 .. .. Call mySUBn End Sub '''''''''''''''''''''''''''''''''''''''''''''''''' My aim is to keep the macro as simple as possible in case it detects an error in a (sub-)subroutine. I would like to have only one single type of behaviour: 1) tell the user which error occurred 2) stop the macro altogether in my case the primitive behaviour is justified because errors will be rare but always have to be corrected manually. From what I understood the only way is to do it like follows: '''''''''''''''''''''''''''''''''''''''''''''''''' Global GiveUp as Boolean Sub myMain() GiveUp = False Call mySUB1 : If GiveUp Then Exit sub Call mySUB2 : If GiveUp Then Exit sub .. .. Call mySUBn End Sub '''''''''''''''''''''''''''''''''''''''''''''''''' and set GiveUp = True in case one of the expected errors occurs. This is ugly, and gets worse if the mySUB.. consist themselves of subroutines. Is there really no "Exit macro" type of statement? Thanks in advance for either confirming my suspicions or - better - showing me a way out Best regards, Bernd |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Crashing excel on exit | Excel Programming | |||
Use of forms in Excel causes crashing | Excel Programming | |||
VBA - Forms Exit Errors | Excel Programming | |||
Calling Forms from Forms - Exit problems | Excel Programming | |||
If a called sub exit, how to the caller exit right away? | Excel Programming |