mercredi 27 septembre 2017

Is it possible to have more than one if statement in an excel VBA User Defined Function

I've created the following function in Excel VBA:

Function GetBTM(bai As Integer, comment As String, amt As Double)
If (bai = 195) Then
  GetBTM = "Customer Wires"
End If

If (bai = 399 And Application.WorksheetFunction.Find("MOV TIT", comment) > 0) Then
  GetBTM = "Customer Wires"
End If

End Function

When I use the function in a spreadsheet, Only the second if statment works, the first statement results in #value. I believe my sytax is correct, so I'm not sure where I am going wrong.

Thanks

Aucun commentaire:

Enregistrer un commentaire