Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Error Handlers

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Error Handlers

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Error Handlers

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
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
Further Clarification with Event Handlers & Class Modules Kevin H. Stecyk[_2_] Excel Programming 2 January 25th 05 05:10 PM
inputbox vs. userform/combobox vs. Windows file handlers ??? List Lurker Excel Programming 2 October 12th 04 11:19 PM
Automation Error, Unknown Error. Error value - 440 Neo[_2_] Excel Programming 0 May 29th 04 05:26 AM
Grouping Event handlers Ripan[_4_] Excel Programming 4 February 7th 04 02:40 PM
Problems with event handlers Italian Job Excel Programming 2 November 12th 03 01:26 AM


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