LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Exiting a macro and aesthetics


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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Crashing excel on exit Lieth Excel Programming 0 January 2nd 06 03:07 PM
Use of forms in Excel causes crashing Arjen Leine Excel Programming 3 November 5th 04 04:09 PM
VBA - Forms Exit Errors jordanctc[_5_] Excel Programming 1 June 30th 04 07:14 PM
Calling Forms from Forms - Exit problems Stuart[_5_] Excel Programming 3 May 25th 04 06:50 AM
If a called sub exit, how to the caller exit right away? luvgreen[_4_] Excel Programming 4 February 24th 04 05:06 PM


All times are GMT +1. The time now is 12:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"