LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Error Handling and Cleanup

In writing a macro, I've read that it's good programming practice to clean
up after the macro is run, by that I mean resetting
application.screenupdating, calculation modes to their original states, that
sort of thing. Now in the case of there being some code for error handling,
that code is typically placed at the end of the macro:

Sub xxx()

main code
If error then goto Error_handler
clean up code
Exit sub

Error_handler:
code
Exit sub

End sub

There's a chance that after handling the error, the macro may be exited
without there being any cleanup. I suppose one can repeat the cleanup code
in the error handler. However, if there are more than a few errorhandlers to
deal with different types of errors, it would be clumsy to repeat the same
cleanup code again and again. How should this problem be dealt with?

TIA.


 
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
Error Handling Kevin Excel Discussion (Misc queries) 4 June 19th 08 12:31 AM
Handling #NUM! error Michel Khennafi Excel Worksheet Functions 1 February 26th 07 08:49 PM
Error Handling Todd Excel Programming 1 February 13th 04 11:29 PM
Error handling John Pierce Excel Programming 3 October 3rd 03 12:17 PM
Error Handling Rob Bovey Excel Programming 0 August 7th 03 12:11 AM


All times are GMT +1. The time now is 07:20 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"