Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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! |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
UDF Error Handling is ignored. Not for everyone?
maybe (with the the VBE):
Tools|options|General tab check break on unhandled errors (I'm betting you have break on all errors) I could mimic your results that way. wrote: 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 -- Dave Peterson |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Error Handling - On Error GoTo doesn't trap error successfully | Excel Programming | |||
Error handling with a handling routine | Excel Programming | |||
error handling off?? | Excel Programming | |||
Error Handling | Excel Programming | |||
Error handling | Excel Programming |