View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default UDF Raising an error

Just a thought. Using an error like #N/A is not good user interfacing IMO.
Far better to give a meanigful message (yeah, I know Excel does, but that is
a throwback from years ago).

Using Dave's UDF as an example

Option Explicit

Function myFunc(myVal As Variant) As Variant

If IsNumeric(myVal) Then
myFunc = myVal * 2
Else
myFunc = "#Value must be numeric"
End If

End Function


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"DMc2005" wrote in message
...
Hi

How can i get a user defined function to return an error code like #n/a.

many thank

d