Hi all,
I am having a lot of trouble to trap the #Value in a function call.
Here is a sample code that I tried and it is not working. Could anyone please be kind enough to take a look?
if item1 and item2 are decimal values, the function will return the correct value.
if item1 or item2 is a string, the function will return the #value which is what I wanted to trap....and I don't know how.
Thanks
I am having a lot of trouble to trap the #Value in a function call.
Here is a sample code that I tried and it is not working. Could anyone please be kind enough to take a look?
if item1 and item2 are decimal values, the function will return the correct value.
if item1 or item2 is a string, the function will return the #value which is what I wanted to trap....and I don't know how.
Thanks
Code:
Function CCB(item1 As Double, item2 As Double) As Variant
Dim test As Variant
test = item1 * item2
If IsError(test) Then
Select Case test
Case CVErr(xlErrValue) '#Value Error
CCB = "Error in input"
End Select
Else
CCB = item1 * item2
End If
End Function