Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error Trapping
For many of my procedures I trap errors with On Error GoTo Handler. Would it
be best to add Resume Next to the Handler? Sub () On Error GoTo Handler [code] Exit Sub Handler: [whatever] Resume Next End Sub Or is there a better approach? Thank you in advance. Jim Kobzeff |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error Trapping
It depends what you want to happen when an error occurs. If your
error handling code can fix the error, use Resume or Resume Next to resume execution in the main section of the code. If your error handling code can't fix the error, you probably don't want to resume, instead exit the sub. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "JK" wrote in message news:HhpNf.2710$DT.491@trnddc06... For many of my procedures I trap errors with On Error GoTo Handler. Would it be best to add Resume Next to the Handler? Sub () On Error GoTo Handler [code] Exit Sub Handler: [whatever] Resume Next End Sub Or is there a better approach? Thank you in advance. Jim Kobzeff |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error Trapping
That depends entirely on the nature of the error. If the error is critical
and there is no point in going onn after the error then resuming next would not cut it. For example if the code needs to read some data from another file, if that file can not be found, it may not make sense to continue on with the code. On the other hand, if it can not find the file but you can reasonably expect the end user to be able to find the file, then your error handler may just show a find file dialog. Once the file has been located then continue. If the user can not find the file then you still would just end the process. There are as many correct ways to handle an error as there are possible errors. -- HTH... Jim Thomlinson "JK" wrote: For many of my procedures I trap errors with On Error GoTo Handler. Would it be best to add Resume Next to the Handler? Sub () On Error GoTo Handler [code] Exit Sub Handler: [whatever] Resume Next End Sub Or is there a better approach? Thank you in advance. Jim Kobzeff |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Error Trapping from WSH | Excel Discussion (Misc queries) | |||
Error Trapping | Excel Programming | |||
Error trapping | Excel Programming | |||
error trapping | Excel Programming | |||
error trapping | Excel Programming |