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

Thanks for this error handler macro. I have one question about it. It is
for a user form.
Where it says "exit sub" , what is the exit sub for? The end sub is the end
of the subrouting which it reaches if there is no error, but if there is an
error doesn't it go to the error handler? so why does it exit the sub?
Thanks,


Private Sub CommandButton1_click()

on Error goto ErrHandler

Code
xxxxxxx

Exit Sub

ErrHandler:
Select Case Err.Number
Case 9
resume
Case Else
MsgBox Err.Number & " " & Err.Description
End Select
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default error routine

So that it doesn't drop into the error handler by defaulter even though
there is no error.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Janis" wrote in message
...
Thanks for this error handler macro. I have one question about it. It is
for a user form.
Where it says "exit sub" , what is the exit sub for? The end sub is the

end
of the subrouting which it reaches if there is no error, but if there is

an
error doesn't it go to the error handler? so why does it exit the sub?
Thanks,


Private Sub CommandButton1_click()

on Error goto ErrHandler

Code
xxxxxxx

Exit Sub

ErrHandler:
Select Case Err.Number
Case 9
resume
Case Else
MsgBox Err.Number & " " & Err.Description
End Select
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default error routine

The exit sub is so it doesn't go through the error handler when there is no
error.

Errhandler:

is just a label that is jumped to if an error occurs - it doesn't mark the
end of the "good" code. If you don't have the exit sub, the code will
always pass through the error handler.

--
Regards,
Tom Ogilvy

"Janis" wrote in message
...
Thanks for this error handler macro. I have one question about it. It is
for a user form.
Where it says "exit sub" , what is the exit sub for? The end sub is the
end
of the subrouting which it reaches if there is no error, but if there is
an
error doesn't it go to the error handler? so why does it exit the sub?
Thanks,


Private Sub CommandButton1_click()

on Error goto ErrHandler

Code
xxxxxxx

Exit Sub

ErrHandler:
Select Case Err.Number
Case 9
resume
Case Else
MsgBox Err.Number & " " & Err.Description
End Select
End Sub



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
need error loop in pivot table routine Jeff C Excel Discussion (Misc queries) 0 May 29th 08 11:08 AM
Error #1004 routine send emails Gus[_2_] Excel Discussion (Misc queries) 0 June 7th 07 01:23 AM
Error Routine Karen Excel Programming 1 September 14th 05 01:51 AM
Error routine needed Jeff Wright[_2_] Excel Programming 1 April 21st 05 04:11 AM
Error Handling Routine kenrmcl Excel Programming 4 April 4th 04 11:50 AM


All times are GMT +1. The time now is 08:51 PM.

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

About Us

"It's about Microsoft Excel"