ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Use IF in a Function (https://www.excelbanter.com/excel-programming/416442-use-if-function.html)

Curious[_6_]

Use IF in a Function
 
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.

Dave Peterson

Use IF in a Function
 
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





Curious wrote:

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.


--

Dave Peterson

Bob Phillips[_3_]

Use IF in a Function
 
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


--
__________________________________
HTH

Bob

"Curious" wrote in message
...
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.





All times are GMT +1. The time now is 05:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com