Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default UDF Error Handling is ignored. Not for everyone?

I have created a new function to try to recreate an example function
that mimics my intent:

Public Function HelloWorld(causeError As Boolean) As String


On Error GoTo ErrorHandler
If (causeError) Then
Err.Raise 1234
Else
HelloWorld = "Hello World"
End If


FunctionExit:
Exit Function


ErrorHandler:
Err.Clear
HelloWorld = "ERROR HAPPENED"
Resume FunctionExit


End Function

For me;
=HelloWorld(FALSE) returns "Hello World"
=HelloWorld(TRUE) returns #VALUE!

For someone else, they get;
=HelloWorld(FALSE) returns "Hello World"
=HelloWorld(TRUE) returns "ERROR HAPPENED"

What could be the problem? I am using Excel 2003, SP2

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default UDF Error Handling is ignored. Not for everyone?

Not very likely, but this could happen if your system has a language where FALSE is "FALSE" but TRUE is a different word. And of
course you could have misspelled TRUE....:-)

--
Kind regards,

Niek Otten

wrote in message ups.com...
I have created a new function to try to recreate an example function
that mimics my intent:

Public Function HelloWorld(causeError As Boolean) As String


On Error GoTo ErrorHandler
If (causeError) Then
Err.Raise 1234
Else
HelloWorld = "Hello World"
End If


FunctionExit:
Exit Function


ErrorHandler:
Err.Clear
HelloWorld = "ERROR HAPPENED"
Resume FunctionExit


End Function

For me;
=HelloWorld(FALSE) returns "Hello World"
=HelloWorld(TRUE) returns #VALUE!

For someone else, they get;
=HelloWorld(FALSE) returns "Hello World"
=HelloWorld(TRUE) returns "ERROR HAPPENED"

What could be the problem? I am using Excel 2003, SP2



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default UDF Error Handling is ignored. Not for everyone?

Ok, I see your point. Just in case, I have simplified things even
further so that the error is not an argument-type issue.

Public Function HW() As String

On Error GoTo ErrorHandler
Err.Raise 1234


FunctionExit:
Exit Function

ErrorHandler:
Err.Clear
HW = "ERROR HAPPENED"
Resume FunctionExit

End Function

I still get:
=HW() returns: #VALUE!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default UDF Error Handling is ignored. Not for everyone?

Dave,

You ARE my HERO! A simple little thing like that.... It would have been
nice if it was going to "Break on that darn error" to open the debugger
in a "break state"! Anyway, thanks a ton. I've been digging for that
answer for two days.

Thanks!!

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 - On Error GoTo doesn't trap error successfully David Excel Programming 9 February 16th 06 05:59 PM
Error handling with a handling routine ben Excel Programming 0 March 15th 05 03:01 PM
error handling off?? Tom Ogilvy Excel Programming 0 August 19th 04 04:31 PM
Error Handling AA2e72E[_2_] Excel Programming 0 April 27th 04 04:06 PM
Error handling John Pierce Excel Programming 3 October 3rd 03 12:17 PM


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