ExcelReady
CourseFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before the interview. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Function guides
  • Blog

Product

  • Certificate

Company

  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Conditional math
  3. How to Use COUNTIF in Excel (With Criteria Examples)

How to Use COUNTIF in Excel (With Criteria Examples)

By ExcelReady Team·Updated October 30, 2026·6 min read

The short answer

COUNTIF counts the cells in a range that meet one condition. Write =COUNTIF(range, criteria), for example =COUNTIF(D2:D9,"Open") to count open tickets. Put text and comparisons in double quotes, like ">=8" or "<>Low". Numbers and cell references go in without quotes. For two or more conditions, use COUNTIFS.

Key takeaways

  • The shape is =COUNTIF(range, criteria): first the cells to check, then what they must match.
  • Text and operators go inside double quotes: "Open", ">=8", "<>Low".
  • In Excel, not equal to is <>, not !=, and greater than or equal to is >=, not =>.
  • To use a cell as the condition, join it to the operator with &: ">"&H1.
  • COUNTIF is not case-sensitive and checks only one condition. Use COUNTIFS for more.
On this page+
  1. What does COUNTIF do in Excel?
  2. How to use COUNTIF: step by step
  3. COUNTIF criteria examples
  4. How to use a cell as the criteria
  5. How to count blank and non-blank cells with COUNTIF
  6. Why is COUNTIF returning 0 or the wrong number?
  7. How to count with more than one condition
  8. Practise it

Excel COUNTIF counts how many cells in a range match one condition: "Open", exactly 2, 8 or more, anything but "Low". You write =COUNTIF(range, criteria), and the only tricky part is how to write the criteria. This guide is for anyone who has to answer "how many?" questions in a spreadsheet or a job test, and it shows every common type of criteria on one small table.

What does COUNTIF do in Excel?#

COUNTIF looks at each cell in a range and counts the ones that meet your condition. The condition is called the criteria. The syntax has two parts:

Excel formula
=COUNTIF(range, criteria)
PartWhat it meansExample
rangeThe cells to checkD2:D9
criteriaWhat a cell must match to be counted"Open", 2, ">=8", G8

COUNTIF works in every version of Excel. It is not case-sensitive, so "open" and "OPEN" count the same.

All the examples below use this support-ticket table in A1:E9:

ABCDE
1TicketAgentPriorityStatusHours
2T-1001JamalHighOpen5
3T-1002SaraLowClosed2
4T-1003JamalMediumClosed8
5T-1004WeiHighClosed12
6T-1005SaraHighOpen3
7T-1006WeiLowClosed1
8T-1007JamalMediumOpen6
9T-1008SaraMediumClosed4

How to use COUNTIF: step by step#

To count matching cells, select an empty cell, type the formula with the range first and the criteria second, and press Enter. Here is how to count the open tickets:

  1. Click an empty cell, for example H2.
  2. Type =COUNTIF( and select the Status column, D2:D9.
  3. Type a comma, then "Open" in double quotes.
  4. Close the bracket and press Enter.
Excel formula
=COUNTIF(D2:D9,"Open")

The result is 3 (T-1001, T-1005 and T-1007). Text criteria always need double quotes. Without them, Excel reads Open as a defined name and shows #NAME?.

COUNTIF criteria examples#

The criteria can be text, a number, a comparison, a wildcard or a cell. This table shows the most useful forms, all on the ticket data:

QuestionFormulaResult
Status is Open=COUNTIF(D2:D9,"Open")3
Took exactly 2 hours=COUNTIF(E2:E9,2)1
Took 8 hours or more=COUNTIF(E2:E9,">=8")2
Took less than 5 hours=COUNTIF(E2:E9,"<5")4
Priority is not Low=COUNTIF(C2:C9,"<>Low")6
Agent name starts with J=COUNTIF(B2:B9,"J*")3
Any ticket ID filled in=COUNTIF(A2:A9,"<>")8

A few rules make all of these work:

  • Numbers on their own need no quotes: 2.
  • Operators go inside the quotes, touching the number: ">=8". Don't add a space.
  • Not equal to is <> in Excel. The != from programming doesn't work, and neither does =>.
  • Wildcards match part of the text: * is any number of characters and ? is exactly one. See how wildcards work in COUNTIF and SUMIF for more.

How to use a cell as the criteria#

Point the criteria at a cell when you want one formula to answer several questions. Say G8:G10 hold the agent names Wei, Sara and Jamal. In H8, type:

Excel formula
=COUNTIF($B$2:$B$9,G8)

Then select H8:H10 and fill down (Windows: Ctrl+D; Mac: ⌘D). You get 2 for Wei, 3 for Sara and 3 for Jamal.

The $ signs lock the range so it stays on rows 2 to 9 as you fill. G8 has no $, so it changes to G9 and G10. Don't put G8 in quotes: "G8" means the letters G and 8, not the name in the cell.

To combine an operator with a cell, keep the operator in quotes and join the cell with &. If H1 holds 5:

Excel formula
=COUNTIF(E2:E9,">"&H1)

This counts tickets over 5 hours: 3 (8, 12 and 6). Change H1 and the answer updates. Writing ">H1" would not work, because inside quotes H1 is just text.

How to count blank and non-blank cells with COUNTIF#

Use "" to count empty cells and "<>" to count cells that are not empty. For example, =COUNTIF(D2:D9,"") counts tickets with no status, and =COUNTIF(D2:D9,"<>") counts tickets that have one. A cell that only looks empty, because it holds a space, is not blank to Excel. If the numbers look off, check for hidden spaces.

For a plain count of filled cells, COUNTA is shorter. The article on COUNT vs COUNTA vs COUNTBLANK explains the differences.

Why is COUNTIF returning 0 or the wrong number?#

COUNTIF returns 0 when nothing matches the criteria exactly, and the cause is usually a small detail. Check these in order:

  1. Missing quotes. =COUNTIF(D2:D9,Open) gives #NAME?. Write "Open".
  2. Extra spaces in the data. "Open " with a trailing space doesn't match "Open". Clean the column with TRIM first.
  3. Numbers stored as text. If the Hours column was imported as text, ">=8" won't count it. Text usually sits on the left of the cell. Convert it with VALUE.
  4. Wrong operator. "=>8" and "!=Low" don't work. Use ">=8" and "<>Low".
  5. Wrong range. Make sure the range is the column you mean, and that it covers every row. A range that stops at row 8 quietly drops the last ticket.

How to count with more than one condition#

COUNTIF checks one condition only. For rows that must match two things at once, such as High priority and Open, use COUNTIFS:

Excel formula
=COUNTIFS(C2:C9,"High",D2:D9,"Open")

The result is 2 (T-1001 and T-1005). The guide to COUNTIFS and SUMIFS with multiple conditions covers this in detail.

For OR logic, such as High or Medium, add two COUNTIFs:

Excel formula
=COUNTIF(C2:C9,"High")+COUNTIF(C2:C9,"Medium")

That gives 3 + 3 = 6. Once you can count, the same criteria work for totals and averages too. Learn how SUMIF adds up matching numbers and how AVERAGEIF finds a conditional average. The COUNTIF function guide is a quick reference for the syntax.

Practise it#

Reading about criteria is easy. Typing them under time pressure is what a job test checks. Practise COUNTIF in a live spreadsheet: you'll count open tickets, use ">=8" and "<>Low", and fill a cell-based formula down a summary table. Or try the exercise on this page first.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

How many tickets have High priority? Click H2 and use COUNTIF on the Priority column (C2:C9), then press Enter.

fx
ABCDEFGHI
1
Ticket
Agent
Priority
Status
Hours
2
T-1001
Jamal
High
Open
5
High priority
3
T-1002
Sara
Low
Closed
2
4
T-1003
Jamal
Medium
Closed
8
5
T-1004
Wei
High
Closed
12
6
T-1005
Sara
High
Open
3
7
T-1006
Wei
Low
Closed
1
8
T-1007
Jamal
Medium
Open
6
9
T-1008
Sara
Medium
Closed
4
10
11
12

Tip: The range comes first, then the word High in double quotes.

Practise this in a lesson

LessonCOUNTIFCount the cells that match a condition, from exact words to number checks like ">=8".Function guideCOUNTIFCount cells that match one condition with COUNTIF: text, numbers, wildcards and cell references. Real examples and a live exercise.

Frequently asked questions

What is the COUNTIF formula in Excel?

+

The formula is =COUNTIF(range, criteria). The range is the cells to check and the criteria is what they must match, such as "Open", 2 or ">=8". It returns how many cells match.

How do I use COUNTIF with text?

+

Put the text in double quotes: =COUNTIF(D2:D9,"Open"). COUNTIF ignores capitals, so open, Open and OPEN all count. Add * for partial matches, like "open".

How do I count cells greater than a number?

+

Put the operator and the number together inside quotes: =COUNTIF(E2:E9,">5"). For a number in a cell, join them with &: =COUNTIF(E2:E9,">"&H1).

Can COUNTIF use two conditions?

+

Not by itself. For AND conditions, use COUNTIFS, for example =COUNTIFS(C2:C9,"High",D2:D9,"Open"). For OR conditions, add two COUNTIFs together.

Why does COUNTIF return 0?

+

Usually the criteria doesn't match the data exactly. Check for missing quotes, extra spaces in the cells, numbers stored as text, or a range that points at the wrong column.

Sources

  • COUNTIF function - Microsoft Support
  • COUNTIFS function - Microsoft Support

Written and checked by the ExcelReady Team. First published October 30, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. What does COUNTIF do in Excel?
  2. How to use COUNTIF: step by step
  3. COUNTIF criteria examples
  4. How to use a cell as the criteria
  5. How to count blank and non-blank cells with COUNTIF
  6. Why is COUNTIF returning 0 or the wrong number?
  7. How to count with more than one condition
  8. Practise it

Keep reading

Conditional math· 7 min read

How to Use SUMIF in Excel

SUMIF adds up the numbers in the rows that meet one condition. Write =SUMIF(range, criteria, sum_range): the cells to check, what they must match, then the numbers to add. For example, =SUMIF(C2:C9,"Travel",D2:D9) totals all Travel claims. Leave out sum_range when the condition is about the numbers themselves.

Conditional math· 7 min read

COUNTIFS and SUMIFS: Multiple Conditions in Excel

COUNTIFS counts rows that meet several conditions, and SUMIFS adds numbers from those rows. Each condition is a pair: a range, then its criteria. A row counts only if it matches every pair. SUMIFS puts the sum range first: =SUMIFS(E2:E9,A2:A9,"North",C2:C9,"Laptop") totals North laptop revenue.

Conditional math· 7 min read

AVERAGEIF and AVERAGEIFS in Excel

AVERAGEIF averages the numbers in rows that meet one condition: =AVERAGEIF(range, criteria, average_range), for example =AVERAGEIF(B2:B9,"Marketing",D2:D9). AVERAGEIFS handles two or more conditions and puts the numbers to average first: =AVERAGEIFS(D2:D9,B2:B9,"Finance",C2:C9,"Senior"). If no row matches, both return the #DIV/0! error, so check your criteria or wrap the formula in IFERROR.

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback. The first lessons are free, with no download.

Start learning for free