Countif

  • Thread starter Thread starter Charles
  • Start date Start date
C

Charles

Hi
Is it possible to use the function, Countif in a macro?
I get a function not defined error when trying:
res=Countif(range,k)

Charles
 
Answer Depends on your version of Excel:
Application.Countif() works on all versions that support VBA
WorksheetFunction.Countif() works on versions since 97
You could combine them
Application.WorksheetFunction.Countif()
(sort of like wearing suspenders and a belt) but I know of no advantages
that offset the extra typing.

WorksheetFunction will give you function names in the Intellisense
dropdown and it give you an argument list for the function you type in
manually. Some functions may behave slightly differently when the call
fails,
http://groups-beta.google.com/group...cf3b8/e69b15d92b5caacb?hl=en#e69b15d92b5caacb
and WorksheetFunction may be as much as 20% faster
http://groups-beta.google.com/group...aca23/05dbe6e736626911?hl=en#05dbe6e736626911
would be a place to start on the differences.

Another option for calling worksheet functions from VBA is
Evaluate("COUNTIF()")
It doesn't matter with COUNTIF, but Evaluate() will treat its argument
as an array formula.

Jerry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Excel Need Countifs Formula Help 0
Countif and Right functions 8
how to do a double lookup 8
Help with countifs 1
COUNTIFS with OR 5
Countif function with two ranges, possible? 2
Multiple Criteria 11
Formula with to Criteria 2

Back
Top