Using "Countif" in macro gives compile error

  • Thread starter Thread starter ashish128
  • Start date Start date
A

ashish128

Hi to all,

I dont know why following line of code in my macro is giving a compile
error

Single line Code >>>

currency_check = Application.WorksheetFunction.COUNTIF(N:N,"<>GBP") -
Application.WorksheetFunction.COUNTIF(N:N,"<>"&"*")

<<<Single line Code

I have declared it as
Dim currency_check As Integer

But the compiler objects at ":" (n:n) part of function and says that,"
Expected List Seperator or )"

Kindly advice.

With Regards,

Ashish
 
You have to pass a range to it, not an Excel cell reference

currency_check =
Application.WorksheetFunction.COUNTIF(Range("N:N"),"""<>GBP""") -
Application.WorksheetFunction.COUNTIF(Range("N:N"),"""<>*""")

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
Try this:-

currency_check = Application.WorksheetFunction.CountIf(Range("N:N"),
"<>GBP") - Application.WorksheetFunction.CountIf(Range("N:N"), "<>" & "*")

Mike
 
You have to pass a range to it, not an Excel cell reference

currency_check =
Application.WorksheetFunction.COUNTIF(Range("N:N"),"""<>GBP""") -
Application.WorksheetFunction.COUNTIF(Range("N:N"),"""<>*""")

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)















- Show quoted text -

Thanks Friend, It worked
 
Try this:-

currency_check = Application.WorksheetFunction.CountIf(Range("N:N"),
"<>GBP") - Application.WorksheetFunction.CountIf(Range("N:N"), "<>" & "*")

Mike














- Show quoted text -

Thanks Friend, It worked
 
Back
Top