Skip to content

COUNTIF

Counts the cells in a range that meet one condition, such as every ticket with the status Open.

Syntax

=COUNTIF(, )

Statistical

All versions of Excel, including Excel for Microsoft 365 and Excel for the web.

Try it

Edit the formula in B13 or change the inputs. The sheet recalculates as you type.

B13
A
B
C
D
1
Ticket
Team
Status
Priority
2
T-201
Billing
Open
3
3
T-202
Access
Closed
1
4
T-203
Billing
Open
4
5
T-204
Network
Open
2
6
T-205
Access
Closed
2
7
T-206
Billing
Pending
3
8
T-207
Network
Closed
1
9
T-208
Access
Open
2
10
T-209
Billing
Closed
1
11
T-210
Network
Pending
2
12
13
Open tickets
4

B13 =COUNTIF(C2:C11,"Open") returns 4

How COUNTIF works

COUNTIF counts how many cells in a range pass a test. It answers "how many open tickets?", "how many orders over 50?" and "how many names start with N?" without any filtering.

Writing the criteria

The criteria can take several forms:

  • A value: "Open" or 3 counts cells equal to it. Text matching ignores case, so "open" also matches Open.
  • A comparison: ">=3", "<100" or "<>Closed". The operator and the value sit together inside one pair of quotes.
  • A wildcard pattern: "Net*" matches anything starting with Net, "*air*" anything containing air, and "?ccess" any single character followed by ccess. To search for a real * or ?, put a ~ before it.
  • A cell reference: E2 uses whatever is in E2, so one formula can be reused for different values.
  • An operator joined to a cell: ">"&E2 counts cells greater than the value in E2.

Two special criteria are worth knowing: "<>" counts cells that are not empty, and "" counts cells that are empty.

Dates

Dates are numbers, so compare them like numbers. To count dates after a cut-off held in E1, use ">"&E1. Typing a date straight into the criteria, such as ">1/31/2025", depends on the regional settings, so a cell reference or ">"&DATE(2025,1,31) is safer.

Limits to know

  • COUNTIF takes one condition. For two or more, use COUNTIFS.
  • Criteria text is limited to 255 characters. Longer strings return #VALUE!.
  • A numeric-looking criterion matches both numbers and text that looks like that number. Long digit strings, such as 16-digit card or account codes, are compared as numbers and can match more than you expect.
  • The range must be a real range reference, not an array created by a formula. Use SUMPRODUCT for that.

COUNTIF versus related functions

COUNT, COUNTA and COUNTBLANK count by cell type, with no condition. To add up the matching numbers rather than count them, use SUMIF. To average them, use AVERAGEIF.

COUNTIF also finds duplicates: =COUNTIF($A$2:$A$11,A2)>1 flags every value that appears more than once.

Arguments

range
The cells to check, such as C2:C11. It can be a column, a row or a block.
criteria
The condition: a value, a cell reference, or an expression such as ">=3", "<>Closed" or "Net*". Text and operators go in quotes. * matches any run of characters and ? matches one character.

Examples

Each example is a live sheet. Change the inputs or the formula and watch the result.

Example 1

Count one status

B13 =COUNTIF(C2:C11,"Open")

Result: 4

T-201, T-203, T-204 and T-208 are open.

B13
A
B
C
D
1
Ticket
Team
Status
Priority
2
T-201
Billing
Open
3
3
T-202
Access
Closed
1
4
T-203
Billing
Open
4
5
T-204
Network
Open
2
6
T-205
Access
Closed
2
7
T-206
Billing
Pending
3
8
T-207
Network
Closed
1
9
T-208
Access
Open
2
10
T-209
Billing
Closed
1
11
T-210
Network
Pending
2
12
13
Open tickets
4

B13 =COUNTIF(C2:C11,"Open") returns 4

Example 2

Count everything except one value

B13 =COUNTIF(C2:C11,"<>Closed")

Result: 6

Ten tickets, four of them closed. The "<>" operator counts the other six.

B13
A
B
C
D
1
Ticket
Team
Status
Priority
2
T-201
Billing
Open
3
3
T-202
Access
Closed
1
4
T-203
Billing
Open
4
5
T-204
Network
Open
2
6
T-205
Access
Closed
2
7
T-206
Billing
Pending
3
8
T-207
Network
Closed
1
9
T-208
Access
Open
2
10
T-209
Billing
Closed
1
11
T-210
Network
Pending
2
12
13
Not closed
6

B13 =COUNTIF(C2:C11,"<>Closed") returns 6

Example 3

Wildcards for partial matches

B13 =COUNTIF(B2:B11,"Net*")

Result: 3

"Net*" matches Network. T-204, T-207 and T-210 belong to it.

B13
A
B
C
D
1
Ticket
Team
Status
Priority
2
T-201
Billing
Open
3
3
T-202
Access
Closed
1
4
T-203
Billing
Open
4
5
T-204
Network
Open
2
6
T-205
Access
Closed
2
7
T-206
Billing
Pending
3
8
T-207
Network
Closed
1
9
T-208
Access
Open
2
10
T-209
Billing
Closed
1
11
T-210
Network
Pending
2
12
13
Teams starting with Net
3

B13 =COUNTIF(B2:B11,"Net*") returns 3

Example 4

Take the limit from a cell

B14 =COUNTIF(D2:D11,"<="&B13)

Result: 7

The operator is joined to B13 with &. Seven tickets have priority 2 or lower. Change B13 and the count follows.

B14
A
B
C
D
1
Ticket
Team
Status
Priority
2
T-201
Billing
Open
3
3
T-202
Access
Closed
1
4
T-203
Billing
Open
4
5
T-204
Network
Open
2
6
T-205
Access
Closed
2
7
T-206
Billing
Pending
3
8
T-207
Network
Closed
1
9
T-208
Access
Open
2
10
T-209
Billing
Closed
1
11
T-210
Network
Pending
2
12
13
Priority at most
2
14
Tickets
7

B14 =COUNTIF(D2:D11,"<="&B13) returns 7

Your turn.

Solve it in the sheet. Every answer is checked, with hints if you need them.

Task 1 of 2

In F2, count the orders for the region named in E2.

Answer in F2.

F2
A
B
C
D
E
F
1
Order
Region
Quantity
Region
Orders
2
SO-301
East
40
East
3
SO-302
West
75
4
SO-303
East
55
Over 50 units
5
SO-304
North
20
6
SO-305
West
90
7
SO-306
East
30
8
SO-307
North
65
9
SO-308
West
50

Common mistakes

  • Putting a cell reference in quotes, such as "E2", counts cells equal to the text E2. Write E2 without quotes, or ">"&E2 to combine it with an operator.
  • A bare number means "equal to". COUNTIF(C2:C9,50) counts cells equal to 50. Use ">=50" for 50 or more.
  • Extra spaces in the data stop a match. "Open " is not "Open". Clean the data with TRIM, or use wildcards such as "Open*".
  • COUNTIF is not case-sensitive, so it cannot tell Ab from AB. Use SUMPRODUCT with EXACT for a case-sensitive count.
  • Criteria longer than 255 characters return #VALUE!, and COUNTIF treats long numeric-looking text, such as 16-digit codes, as numbers, so it can match more than you expect.

Questions people ask

How do I count cells greater than a number?

Use an operator inside quotes: `=COUNTIF(B2:B9,">100")`. To read the number from a cell, join them: `=COUNTIF(B2:B9,">"&E2)`.

Can COUNTIF count with two conditions?

Not on its own. Use COUNTIFS: `=COUNTIFS(A2:A9,"East",B2:B9,">100")`. For OR logic, add two COUNTIF results together.

How do I count cells that contain certain text?

Wrap the text in asterisks: `=COUNTIF(A2:A9,"*air*")` counts cells that contain air anywhere.

How do I count duplicates with COUNTIF?

Anchor the range and point at the first cell: `=COUNTIF($A$2:$A$11,A2)` and fill down. Any result above 1 is a duplicate.

Is COUNTIF case-sensitive?

No. `"open"` matches `Open` and `OPEN`.

Learn COUNTIF in a real sheet.

COUNTIF is taught in Data analysis with formulas, lesson 3: Criteria with operators. Each lesson is a short, graded exercise like the one above.