You are here:

Excel/countif using two sets of criteria


Hi Tom

In cell C2 of my spreadsheet, I would like to count the amount of times there is a blank cell in column A, AND the words "OK to raise" in column C.  I can get countif to work for one set of criteria, is there a function that can consider both criteria?  Will I need an Array formula?  I am in EXCEL 2003.




In Excel 2003 you would need an array type formula.  You can avoid array entry by using sumproduct in this case.  (so this formula can be entered normally - however it can not refer to an entire column because it is still subject to the limitations of an array formula).

=sumproduct(--(A1:A5000=""),--(C1:C5000="OK to raise"))

sometimes cells appear blank, but may not be blank.  If someone cleared a cell in column A with the spacebar, then the first part of the formula would not see it as blank.  

You can do

=sumproduct(--(len(trim(A1:A5000))=0),--(C1:C5000="OK to raise"))

which is a little more robust.  

Also, the second part is looking for cells that contain "OK to raise" as a phrase - not a substring of a longer phrase.  

Change the 5000 to the last row you want to check.  Be realistic since the more rows included, the longer it could take to calculate.

Tom Ogilvy

About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here


All Answers

Answers by Expert:

Ask Experts


Tom Ogilvy


Selected as an Excel MVP by Microsoft since 1999. Answering Excel questions in Allexperts since its inception in 2001. Able to answer questions on almost all aspects of Excel's internal capabilities. If seeking a VBA solution, please specify that in your question itself so I give you the answer you want. [Excel has weak protection - if you are distributing an application, I don't answer questions on how to protect your project from your users.]


Extensive experience.

Master of Science (MS) degree Operations Research (ORSA)

Awards and Honors
Microsoft MVP in Excel.

©2017 All rights reserved.