Hello,
I don't know how to setup the proper data definitions. I think you can see from the code what I'm trying to do. Often, one or both of the variables will be nil. If both are nil, I want to return nil. If one is nil, I want to return the other. If both are numbers, I want to return the sum. Usually the numbers are currency, but could be integer or mixed currency and integer.
The code goes to the return in the function and gets an error. I don't understand the error.
Thanks for your help.
Code:Public Function Add_Blanks(var1 As Variant, var2 As Variant) As Variant
'
' Add numbers even if blank
'
Dim sum1 As Variant
If var1 = "" And var2 = "" Then
Add_Blanks = ""
Exit Function
End If
If var1 = "" Then
Add_Blanks = var2
Exit Function
End If
If var2 = "" Then
Add_Blanks = var1
Exit Function
End If
Add_Blanks = var1 + var2
End Function
Private Sub tadd()
'
' test use only
'
Dim abc As Long
abc = Add_Blanks("", "")
MsgBox ("Answer is ... " & abc)
End Sub