Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
GPO GPO is offline
external usenet poster
 
Posts: 12
Default Error handling

(excel 2000, 2003, 2007)

Hello All

I have a function where I want the error handling for the most part to be
On Error GoTo HandleError

but for certain blocks I want it to be
On Error Resume Next

How do I do this?

Regards

GPO


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Error handling

Just switch between the two errors mode as required

On Error GoTo HandleError
'section 1 code
On Error Resume Next
'section 2 code
On Error GoTo HandleError
'section 3 code


"GPO" wrote:

(excel 2000, 2003, 2007)

Hello All

I have a function where I want the error handling for the most part to be
On Error GoTo HandleError

but for certain blocks I want it to be
On Error Resume Next

How do I do this?

Regards

GPO


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Error handling

I tend to handle that by placing the Resume Next code into a separate
procedure, as the error handler is reset on exit.

Sub TestError()

On Error GoTo HandleError

'do stuff

Call CalledProc

Debug.Print 1 / 0

Exit Sub

HandleError:
MsgBox Err.Number & " : " & Err.Description
End Sub

Function CalledProc()

On Error Resume Next
Debug.Print 1 / 0
End Function

It may seem unnecessary, but I find it keeps the code more structured, and
gives m e all the control that I need

--
__________________________________
HTH

Bob

"GPO" wrote in message
...
(excel 2000, 2003, 2007)

Hello All

I have a function where I want the error handling for the most part to be
On Error GoTo HandleError

but for certain blocks I want it to be
On Error Resume Next

How do I do this?

Regards

GPO




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
Error handling error # 1004 Run-time error [email protected] Excel Programming 3 May 20th 08 02:23 PM
Set Error handling INSIDE error-trap Michelle Excel Programming 6 May 3rd 08 03:30 PM
Error Handling - On Error GoTo doesn't trap error successfully David Excel Programming 9 February 16th 06 05:59 PM
Error handling. Francis Brown Excel Programming 3 December 1st 05 12:47 AM
Error handling with a handling routine ben Excel Programming 0 March 15th 05 03:01 PM


All times are GMT +1. The time now is 07:31 AM.

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"