SQLExcelHTML & CSSTouch typingBlogChoose a course
Lurndo › Blog › Excel
  1. Short answer
  2. What does COUNTIFS do in Excel?
  3. How do you write a COUNTIFS formula?
  4. How do you count with two conditions?
  5. How do you count between two values with COUNTIFS?
  6. Which criteria can you combine?
  7. How do you build a summary by category and person?
  8. Can COUNTIFS work with OR?
  9. Why isn't my COUNTIFS working?
  10. Which functions are like COUNTIFS?
  11. Frequently asked questions

Excel COUNTIFS examples: counting with multiple criteria, including between two values

How many items over £5 did Grace sell? On a charity shop's real sheet you'll see how COUNTIFS counts row by row, and you can write one yourself right away.

C

Christophe, founder of Lurndo
November 6, 2026 · 7 min read

COUNTIFS counts the rows that meet all your conditions at once. You give it a range and its criteria each time, as in =COUNTIFS(B2:B16,"Clothing",C2:C16,">5"). There's no range to count: the function counts rows. All the ranges must be the same size. To count between two values, use two conditions on one column, and for one thing or another, add two formulas together.

Exercise: right in your browser, on real data

Practise this: the lesson on SUMIFS, free

Sources: 2 sources you can check

Four paper tally marks with a yellow stroke across them stand on a stack of green spreadsheet cells, above two rows of cells in light and dark shades, on light green paper.

What does COUNTIFS do in Excel?

COUNTIFS counts the rows that meet all your conditions at once. Where COUNTIF asks one question, COUNTIFS asks as many as you need: is it clothing, and did it cost more than £5? =COUNTIFS(B2:B16,"Clothing",C2:C16,">5") returns 3, because three items of clothing cost more than £5. In a Dutch copy of Excel, the same function is called AANTALLEN.ALS.

Every example uses a week of sales at the Second Chance charity shop in Gloucester, the fourth client in our Excel course. If you'd rather learn the function step by step, follow the lesson on multiple conditions. If you're still counting with one condition, the COUNTIF examples show every kind of criteria. Here we look at what changes once a second condition comes in.

How do you write a COUNTIFS formula?

In pairs: a range, then the criteria that belong to that range. The first pair is required, and you can use up to 127 pairs (Microsoft). There's no separate range to count, like the sum range in SUMIFS: the function counts rows.

=COUNTIFS(criteria_range1,criteria1,[criteria_range2,criteria2],…)
ArgumentWhat it isRequired?
criteria_range1The cells where you test the first conditionYes
criteria1The first condition: text, a number, ">5" or a cellYes
criteria_range2, criteria2Another range with its condition, and so onNo

Row by row: Excel looks at the first cell of every range, then the second, and so on. If they all match, that row counts as 1.

With Dutch or Belgian regional settings you'd write =AANTALLEN.ALS(B2:B16;"Clothing";C2:C16;">5"). Only the function name and the separator change.

How do you count with two conditions?

Coordinator Yasmina at Second Chance wants to know how much pricier clothing left the shop. This is the whole sheet, with all fifteen sales. G2 holds a price limit of £10, which we'll refer to in a moment.

RowA: ItemB: CategoryC: Price (£)D: DayE: Volunteer
2Dress greenClothing12MonSophie
3Book fictionBooks2MonOmar
4LampHousehold8TueSophie
5T-shirt SClothing3TueGrace
6Dressing gownClothing6WedOmar
7PuzzleToys4WedGrace
8Book cookingBooks3ThuSophie
9RadioElectrical15ThuOmar
10T-shirt XLClothing4FriSophie
11Dress blackClothing18FriGrace
12What? GameToys5SatOmar
13VaseHousehold7SatGrace
14T-shirt MClothing3SatSophie
15BookendHousehold9SatOmar
16Kids' bikeToys35SatGrace
=COUNTIFS(B2:B16,"Clothing",C2:C16,">5")

The formula returns 3. Excel goes down the rows and tests both conditions on each one. Clothing appears six times on the sheet, but only Dress green, Dressing gown and Dress black cost more than £5. The £15 radio drops out on its category, the T-shirts on their price. It doesn't matter that the conditions sit in different columns, because the function always looks at one row at a time.

Your turn. The exercise runs on Second Chance's real sheet, and you type the formula as you would in Excel.

Try it: Grace above £5

How many items over £5 did Grace sell? Work it out in I2 with COUNTIFS.

ABCDEFGHIJ
1ItemCategoryPriceDayVolunteerLimit
2Dress greenClothing£12.00MonSophie£10.00
3Book fictionBooks£2.00MonOmar
4LampHousehold£8.00TueSophie
5T-shirt SClothing£3.00TueGrace
6Dressing gownClothing£6.00WedOmar
7PuzzleToys£4.00WedGrace
8Book cookingBooks£3.00ThuSophie
9RadioElectrical£15.00ThuOmar
10T-shirt XLClothing£4.00FriSophie
11Dress blackClothing£18.00FriGrace
12What? GameToys£5.00SatOmar
13VaseHousehold£7.00SatGrace
14T-shirt MClothing£3.00SatSophie
15BookendHousehold£9.00SatOmar
16Kids' bikeToys£35.00SatGrace
17
I2

Your formula ran in your own browser, on a real calculation engine. Then we run it again on a hidden version of the sheet, with other prices and volunteers. Anyone who just types 3 gets caught there.

How do you count between two values with COUNTIFS?

Use the same column twice, with a lower limit and an upper limit. This is the example most people look this function up for, because COUNTIF can't do it in one go. Excel tests both conditions on the same cell, and only what falls between the limits counts. Try it here.

Try it: the middle of the range

How many items cost £5 or more, and £10 or less? Work it out in I2.

ABCDEFGHIJ
1ItemCategoryPriceDayVolunteerLimit
2Dress greenClothing£12.00MonSophie£10.00
3Book fictionBooks£2.00MonOmar
4LampHousehold£8.00TueSophie
5T-shirt SClothing£3.00TueGrace
6Dressing gownClothing£6.00WedOmar
7PuzzleToys£4.00WedGrace
8Book cookingBooks£3.00ThuSophie
9RadioElectrical£15.00ThuOmar
10T-shirt XLClothing£4.00FriSophie
11Dress blackClothing£18.00FriGrace
12What? GameToys£5.00SatOmar
13VaseHousehold£7.00SatGrace
14T-shirt MClothing£3.00SatSophie
15BookendHousehold£9.00SatOmar
16Kids' bikeToys£35.00SatGrace
17
I2

Limits: ">5" and ">=5" differ by exactly the items at £5. Always read twice whether the limit itself should count.

A date range works the same way, because a date is a number to Excel. With a real date in column D, =COUNTIFS(D2:D16,">="&DATE(2026,11,1),D2:D16,"<"&DATE(2026,12,1)) would count the sales of all of November. For how that handles times on the last day, see SUMIFS with a date range.

Which criteria can you combine?

All the ones you know from the lesson on criteria: text, numbers, comparisons, wildcards and references to a cell, in any mix. Microsoft lists the same wildcards as for COUNTIF (Microsoft). On Second Chance's sheet, that looks like this:

QuestionFormulaResult
Clothing on Saturday=COUNTIFS(B2:B16,"Clothing",D2:D16,"Sat")1
Sophie's sales above the limit in G2=COUNTIFS(E2:E16,"Sophie",C2:C16,">"&G2)1
Saturday, but not Grace=COUNTIFS(D2:D16,"Sat",E2:E16,"<>Grace")3
T-shirts on Saturday=COUNTIFS(A2:A16,"T-shirt*",D2:D16,"Sat")1
Blank cells in column E=COUNTIFS(E2:E16,"")0

The criteria with a cell are especially worth it. Put the limit in G2 and refer to it with ">"&G2, and Yasmina can change the limit without opening the formula. Only the operator goes in the quotation marks; the reference stays outside.

How do you build a summary by category and person?

With one formula you fill across and down, thanks to mixed references. Put the categories below each other in column K and the names side by side in row 1, then write this in L2:

=COUNTIFS($B$2:$B$16,$K2,$E$2:$E$16,L$1)

Fill that formula right and down, and the ranges stay put, while $K2 follows the row and L$1 follows the column. That gives you a cross table:

SophieOmarGrace
Clothing312
Books110
Household111
Toys012
Electrical010

Together that makes 15, as many as there are rows on the sheet. It's a handy check too: if the total is off, a category or name somewhere has a typo.

Can COUNTIFS work with OR?

Not with ordinary criteria: all the conditions must hold at once. That's why =COUNTIFS(B2:B16,"Clothing",B2:B16,"Books") returns 0. No single cell is clothing and books at the same time. For one thing or another, add two formulas: =COUNTIFS(B2:B16,"Clothing")+COUNTIFS(B2:B16,"Books") returns 8, six items of clothing and two books.

That addition works because a row has only one category. Ask for clothing or anything of Sophie's, and one row can meet both. Six items of clothing plus five sales by Sophie makes 11, while the real answer is 8: Sophie's three items of clothing are in the sum twice. So subtract them again, with a third formula that tests both conditions together.

Why isn't my COUNTIFS working?

Most mistakes give no message, just a count that's too low. First check whether your conditions can hold together, then work through this list.

You get 0 even though the rows exist

Spaces are the usual suspect. You can't see a trailing space in a cell, but "Clothing" won't find that cell any more. Microsoft names leading and trailing spaces as a cause of unexpected results (Microsoft). ">G2" gives 0 too, because Excel then looks for the letters G2 rather than the value in that cell.

The formula returns #VALUE!

Then the ranges usually aren't the same size. Each additional range must have as many rows and columns as the first (Microsoft). They don't have to sit next to each other, but they do have to be the same length. =COUNTIFS(B2:B16,"Clothing",E2:E15,"Sophie") stops on that single row of difference.

Criteria that refer directly to an empty cell are read as 0. With H1 empty, =COUNTIFS(C2:C16,H1) looks for prices of £0, and returns 0 without a warning.

A range is missing

Each criteria belongs to a range of its own. =COUNTIFS(E2:E16,"Omar",">5") doesn't work, because ">5" doesn't say which column to look in. Even when two conditions are about the same column, you write that column twice.

Which functions are like COUNTIFS?

COUNTIFS is the counter of a family. The other members do the same thing but work out something else, which is why they start with the range of numbers.

FunctionWhat it doesExampleResult
COUNTIFSCounts rows=COUNTIFS(B2:B16,"Clothing",E2:E16,"Sophie")3 items
SUMIFSAdds up numbers=SUMIFS(C2:C16,B2:B16,"Clothing",E2:E16,"Sophie")£19
AVERAGEIFSTakes the average=AVERAGEIFS(C2:C16,B2:B16,"Clothing",E2:E16,"Sophie")£6.33

If you want amounts rather than items, read SUMIFS with examples. Averages with a condition are in AVERAGEIF and AVERAGEIFS, and every function with its Dutch name is on the Excel cheat sheet.

If you want to master counting with conditions, follow module 4 of the Excel course. You start with COUNTIF and build up to multiple conditions in six short lessons, and the first modules are free.

Frequently asked questions

What's the difference between COUNTIF and COUNTIFS?

COUNTIF counts with one condition, COUNTIFS with one or more. With two conditions, a row only counts when both hold. If you always use COUNTIFS, you've only got one function to remember. With one pair it does the same as COUNTIF, and you can add a condition later without rewriting anything.

How do you count with OR instead of AND?

Add two formulas together, one per condition. For clothing or books, write =COUNTIFS(B2:B16,"Clothing")+COUNTIFS(B2:B16,"Books"). If a row could meet both conditions, subtract the rows that meet both. Otherwise they count twice, and your total comes out too high without any warning from Excel.

How do you count cells between two values?

Use the same column twice, with a lower and an upper limit: =COUNTIFS(C2:C16,">=5",C2:C16,"<=10"). Watch the limits. With >= and <=, the values 5 and 10 count themselves; with > and < they don't. A date range works the same way with dates as the limits, because a date is a number to Excel.

Why does COUNTIFS return 0?

Usually no single row meets all the conditions at once. That happens when you ask for two different texts on the same column, because a cell can't be both. Also check for spaces in the cells, numbers stored as text, and a reference that ended up inside the quotation marks.

Can COUNTIFS count blank cells?

Yes, with the criteria "": =COUNTIFS(E2:E16,"") counts the empty cells, and "<>" counts what isn't empty. Don't confuse that with criteria that refer to an empty cell. According to Microsoft, COUNTIFS reads those as the value 0, so you'd be counting zeros instead of blanks.

Practise this in the course

Every lesson explains first and then lets you practise yourself, with a real spreadsheet in your browser.

  • SUMIFSCounting and adding with conditions · Several conditions
  • COUNTIFCounting and adding with conditions · Counting what matches
  • CriteriaCounting and adding with conditions · Criteria with operators
Start Excel for free

Sources

  1. Microsoft Support, COUNTIFS function
  2. Microsoft Support, COUNTIF function
C

Christophe, founder of Lurndo

Christophe builds Lurndo from Belgium, with short, playful exercises for SQL, Excel, HTML & CSS and touch typing that show straight away what your answer does. On this blog, Christophe answers the questions people run into while learning, with sources you can check yourself.

Read next

  • AVERAGEIF and AVERAGEIFS examples: one condition or several, and why you get #DIV/0!Two functions with nearly the same name and their arguments in a different order. On a charity shop's real sheet you'll see when to use which, and where an average can lead you astray.Excel · November 6, 2026 · 7 min read
  • IFERROR and IFNA in Excel: catching errors without hiding the real onesA #DIV/0! or #N/A looks messy, but it's information too. On the sheets of a swimming pool and a bike courier, you'll see how to catch them neatly, and when to leave them alone.Excel · November 6, 2026 · 6 min read

SQL

  • Topics
  • All lessons
  • Cheat sheet
  • Sandbox

Excel

  • Topics
  • All lessons
  • Cheat sheet
  • Shortcuts

HTML & CSS

  • Topics
  • All lessons
  • Cheat sheet

Touch typing

  • Topics
  • All lessons
  • Cheat sheet
  • Typing test

Lurndo

  • Dashboard
  • Leaderboard
  • Premium
  • Account
  • Blog
  • FAQ
  • Contact & support
  • Privacy

Ask AI about Lurndo

Nederlands