Templates, guides & honest tool reviews for small business

Monday, November 30, 2026

COUNTIFS in Excel: Count Rows That Match Every Condition

Section: Excel & Google Sheets

COUNTIFS in Excel - explanatory illustration for COUNTIFS in Excel
Illustration: COUNTIFS in Excel

COUNTIFS in Excel counts the rows that meet every condition you give it. =COUNTIFS(B2:B5,"=Yes",C2:C5,"=Yes") returns 2 on Microsoft's sample data, because two salespeople beat both their first and second quarter quotas. It is the counting partner of SUMIFS: same shape, same criteria rules, different output. This guide covers the syntax, the rules Microsoft states for the ranges, the published examples checked by hand, counting between two values, dates, cell references, and the mistakes that produce a zero.

What COUNTIFS does

Microsoft describes COUNTIFS as applying criteria to cells across multiple ranges and counting the number of times all criteria are met. One condition gives you a count; several conditions give you a count of the rows that satisfy all of them at once.

That "all at once" is the whole value of the function. A single COUNTIF tells you how many orders came from the north; COUNTIFS tells you how many north orders were over 500 and shipped late, which is the number a review meeting actually asks for.

The syntax

=COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2], ...)

  • criteria_range1 is the first range to test, and criteria1 is the test applied to it.
  • Further pairs are optional, and Microsoft allows up to 127 of them.
  • There is no sum range and no first argument for the numbers. COUNTIFS counts rows, so every argument is a test.
COUNTIFS arguments - explanatory illustration for COUNTIFS in Excel
COUNTIFS arguments (explanatory illustration, not a software screenshot).

The rules Microsoft states

Four rules from the same page decide whether a formula works:

  • Every additional range must have the same number of rows and columns as the first, though the ranges do not have to sit next to each other.
  • Each range's criteria are applied one cell at a time: if the first cell in every range meets its test, the count goes up by one, and so on down the rows.
  • If a criterion is a reference to an empty cell, COUNTIFS treats that empty cell as a 0 value.
  • Wildcards work: a question mark matches one character, an asterisk matches any sequence, and a tilde in front of either finds the literal character.

If the data lives in an Excel Table, every range grows with the table, which removes the whole class of mistake where one range stops a row short.

The same-size rule is the one that bites quietly. Excel does not always object when the ranges differ in height, it just pairs the wrong cells and returns a count that looks reasonable.

Microsoft's first example, checked

The sample is a grid of four salespeople and three quarters, with Yes or No in each cell: Davidoski Yes No No, Burke Yes Yes No, Sundaram Yes Yes Yes, Levitan No Yes Yes.

  • =COUNTIFS(B2:D2,"=Yes") returns 1, the single quarter in which Davidoski beat quota.
  • =COUNTIFS(B2:B5,"=Yes",C2:C5,"=Yes") returns 2, because only Burke and Sundaram beat both Q1 and Q2.
  • =COUNTIFS(B5:D5,"=Yes",B3:D3,"=Yes") returns 1, the one quarter where Levitan and Burke both beat quota, which is Q2.

I counted all three from the table before writing them down and they match. The third formula is worth studying: the two ranges sit on different rows and neither is a column, which is exactly the flexibility the function allows.

Microsoft's COUNTIFS example - explanatory illustration for COUNTIFS in Excel
Microsoft's COUNTIFS example (explanatory illustration, not a software screenshot).

Counting between two values

Microsoft's second example counts numbers between 1 and 6 in a column holding 1 to 6, with dates beside them. The formula is =COUNTIFS(A2:A7,"<6",A2:A7,">1") and it returns 4, because 2, 3, 4 and 5 qualify and the two bounds are excluded.

Two conditions on the same range is the standard way to build a between test, since COUNTIFS has no between operator. Change the operators to "<=6" and ">=1" and the same formula counts all six. This is the pattern behind every age band, price band and date window you will build.

Counting between two values - explanatory illustration for COUNTIFS in Excel
Counting between two values (explanatory illustration, not a software screenshot).

Criteria that point at a cell

A criterion can be a cell reference, and when it is, the comparison has to be joined to it with an ampersand. Microsoft's third formula does exactly that: =COUNTIFS(A2:A7,"<"&A6,B2:B7,"<"&B4) returns the same 2 as the version with the constants typed in.

The ampersand version is the one to use in a real workbook, because it lets a reader change the threshold in a cell instead of opening the formula. A criterion of just A6 without the operator counts rows equal to that value, which is a different question.

Dates as criteria

Dates are numbers behind the formatting, so the same operators work: ">="&DATE(2026,1,1) counts everything from the start of 2026 onwards, and a second pair with "<="&DATE(2026,3,31) closes the quarter.

Typing a date as text inside the criterion works only when the text matches your regional date format, which is why Microsoft's own example writes 5/3/2011 directly and why the DATE version is safer in a shared file. If a date criterion counts nothing at all, check whether the column holds text that looks like dates.

COUNTIFS compared with COUNTIF and SUMIFS

SUMIF adds values that meet one condition and COUNTIF counts them. Add an S and both take several conditions, with one difference that catches people: SUMIFS starts with the range to add, while COUNTIFS starts with the first range to test.

If you need to add rather than count, use SUMIFS with the same criteria pairs. If you need to count unique values, COUNTIFS cannot do it directly; the usual route is a helper column or a formula built on COUNTIF over a shrinking range.

Common problems

  • A count of zero. Text criteria missing their quotes, or the criteria pointing at the wrong column.
  • A count that is too high. Ranges of different heights, so the pairs no longer line up with the rows you meant.
  • A date window that counts everything. The dates are stored as text. Check alignment: dates sit right, text sits left.
  • An empty-cell criterion that counts blanks unexpectedly. A reference to an empty cell is read as 0.
  • A wildcard matching more than intended. "A*" also matches "Axle". Put a tilde before a literal asterisk.
  • A count that disagrees with a filtered view. Hidden rows still count. COUNTIFS reads the range, not the screen.
Why COUNTIFS returns 0 - explanatory illustration for COUNTIFS in Excel
Why COUNTIFS returns 0 (explanatory illustration, not a software screenshot).

Questions and answers

What is the difference between COUNTIF and COUNTIFS?

COUNTIF takes one condition. COUNTIFS takes several and counts only the rows where all of them are true.

Can COUNTIFS count blank cells?

Yes, with a criterion of "" for empty and "<>" for non-empty. Check the result against a filtered view the first time you use it.

Does COUNTIFS count duplicates?

It counts every row that matches, including duplicates. For a unique count you need a different approach.

Can the ranges be on another sheet?

Yes, as long as every range has the same number of rows and columns.

Does COUNTIFS work in Google Sheets?

Yes, with the same argument order and the same wildcard rules. Check Google's function page before copying a formula across.

Official references

العربية