Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Can you have more than one ErrorHandlers within the same code?
If you can - How If not, is there anything else I can do? I thought it might have been as easy as ErrorHandler and adding a one on the end, second with adding a two on the end etc, but alas it failed miserably. Below is the only one that would work (being the only one within the code) On Error GoTo ErrorHandler 'Code ErrorHandler: MsgBox "You have an error" & vbNewLine & _ " ", , " ERROR" Many thanks to Peter Rooney for his help on my last problem |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi John,
You certainly can - I don't know why your previous attempt didn't work. Try something like: Sub Foo() On Error goto ErrorHandler_Date ' code to get date from user On Error goto ErrorHandler_Number ' code to get number from user On Error Goto 0 'Skip the error handlers Exit Sub ErrorHandler_Date: MsgBox "Please enter a date" exit sub ErrorHandler_Number: MsgBox "Please enter a date" exit sub End Sub JohnUK wrote: Can you have more than one ErrorHandlers within the same code? If you can - How If not, is there anything else I can do? I thought it might have been as easy as ErrorHandler and adding a one on the end, second with adding a two on the end etc, but alas it failed miserably. Below is the only one that would work (being the only one within the code) On Error GoTo ErrorHandler 'Code ErrorHandler: MsgBox "You have an error" & vbNewLine & _ " ", , " ERROR" Many thanks to Peter Rooney for his help on my last problem |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
One way:
Public Sub foo() On Error GoTo Error_Handler1 'code here On Error GoTo Error_Handler2 'more code here Exit_Sub: Exit Sub Error_Handler1: 'Handle error Resume Exit_Sub Error_Handler2: 'Handle error 2 Resume Exit_Sub End Sub In article , JohnUK wrote: Can you have more than one ErrorHandlers within the same code? If you can - How If not, is there anything else I can do? I thought it might have been as easy as ErrorHandler and adding a one on the end, second with adding a two on the end etc, but alas it failed miserably. Below is the only one that would work (being the only one within the code) On Error GoTo ErrorHandler 'Code ErrorHandler: MsgBox "You have an error" & vbNewLine & _ " ", , " ERROR" Many thanks to Peter Rooney for his help on my last problem |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Further Clarification with Event Handlers & Class Modules | Excel Programming | |||
inputbox vs. userform/combobox vs. Windows file handlers ??? | Excel Programming | |||
Automation Error, Unknown Error. Error value - 440 | Excel Programming | |||
Grouping Event handlers | Excel Programming | |||
Problems with event handlers | Excel Programming |