Quote Originally Posted by ratvoleur
Hi,

I have this code

function number( n as double) as double

number=n+1

end function


Simple

Now I want; if someone decide to put a string instead a double in the cell to show something like msgbox("error") and erase #value!

Please help me!

Thx
One easy way (not sure it is the best) is to do the following:
Function number(n As Variant) As Variant

If IsNumeric(n) Then
   number = n + 1
Else
   Call MsgBox("Error", vbCritical )
   number = ""
End If

End Function