Error is thrown before the error handler can handle it
Posted: Mon Apr 22, 2019 6:50 am
Hi.
I tried to emulate Excel IFERROR function.
I tried to do it in two ways:
[First]
[Second]
The problem is when the expression is erroneous, it's shown in the cell and the error handling inside the functions doesn't have a chance to handle it.
Is there any way to achieve this?
Thanks.
I tried to emulate Excel IFERROR function.
I tried to do it in two ways:
[First]
Code: Select all
Function IFERROR(Expression as Variant, DefaultValue as Variant)
If ISERROR(Expression) Then
IFERROR = DefaultValue
Else
IFERROR = Expression
End If
End Function
Code: Select all
Function IFERROR(Expression as Variant, DefaultValue as Variant)
On Error Goto ERRHANDLER
IFERROR = Expression
Exit Function
ERRHANDLER:
IFERROR = DefaultValue
End Function
Is there any way to achieve this?
Thanks.