chrisjones
08-04-2010, 02:18 AM
Several Excel built in functions produce specific errors for certain scenarios. I would like to do the same thing, I have written a short example where if you enter a negative or positive number it should display the rasied errror msg in the cell. However it just shows "#VALUE" ??
Public Function test(ByVal i As Integer) As Integer
If i < 0 Then
'test = 0
Err.Raise Number:=vbObjectError + 1, Source:="test method", Description:="i cannot be negative"
ElseIf i > 0 Then
Err.Raise Number:=vbObjectError + 2, Source:="test method", Description:="i cannot be positive"
Else
test = 1
End If
End Function
Thanks
Chris
Public Function test(ByVal i As Integer) As Integer
If i < 0 Then
'test = 0
Err.Raise Number:=vbObjectError + 1, Source:="test method", Description:="i cannot be negative"
ElseIf i > 0 Then
Err.Raise Number:=vbObjectError + 2, Source:="test method", Description:="i cannot be positive"
Else
test = 1
End If
End Function
Thanks
Chris