Use IF in a Function

C

Curious

When testing this function, I encountered "Invalid quantifier" message
and the highlighted word is "InvoiceNote.Find".

Function AccruedBillable(State As String, InvoiceNote As String) As
Variant

Application.Volatile (True)

On Error Resume Next

If InvoiceNote.Find(What:="Billable", _
LookIn:=xlFormulas, _
LookAt:=xlPart, MatchCase:=False, SearchFormat:=False) Then

Select Case State

Case Is = "ME"
AccruedBillable = 400

Pease shed a light on how to fix it. Thanks in advance.

H.Z.
 
D

Dave Peterson

InvoiceNote is declared a string. Is that what you wanted--or should it have
been a range or a worksheet?

If you're looking to see if a string contains the word billable, you can use
instr()

if instr(1,invoicenote,"billable",vbtextcompare) > 0 then
'yep
else
'nope
end if
 
B

Bob Phillips

Perhaps

Function AccruedBillable(State As String, InvoiceNote As String) As
Variant

Application.Volatile (True)

On Error Resume Next

If Range("InvoiceNote").Find(What:="Billable", _
LookIn:=xlFormulas, _
LookAt:=xlPart, MatchCase:=False, SearchFormat:=False) Then

Select Case State

Case Is = "ME"
AccruedBillable = 400
 
Top