How do I get a UDF to return #N/A, as if from =NA()
Function foo(v)
' try v = 0 and v = 1
On Error GoTo errH
foo = 1 / v
Err.Raise 12345
Exit Function
errH:
If Err.Number = 11 Then
foo = CVErr(xlErrDiv0)
ElseIf Err.Number = 12345 Then
foo = CVErr(xlErrNA)
Else
foo = CVErr(xlErrValue)
End If
End Function
here are the XlCVError constants
xlErrDiv0
xlErrNA
xlErrName
xlErrNull
xlErrNum
xlErrRef
xlErrValue
Regards,
Peter T
"Barb Reinhardt" wrote in message
...
I have a user defined function and at times I want it to return =NA() in
the
cell. How do I do this? I can get it to return a text string, but not a
formula.
Thanks,
Barb Reinhardt
|