
COUNTIF counts the cells that meet a condition. When you need several conditions at once, use COUNTIFS.
COUNTIF syntax
=COUNTIF(range, criteria)=COUNTIF(B2:B100,"London") cells that say London
=COUNTIF(C2:C100,">1000") values above 1000
=COUNTIF(C2:C100,"<>0") values that are not zero
=COUNTIF(B2:B100,E1) criteria in another cellComparison operators (>, <, >=, <>) go inside quotes. To combine an operator with a cell value: =COUNTIF(C2:C100,">"&E1).
Wildcards
*any number of characters:"A*"starts with A,"*net*"contains "net".?a single character:"A??"three letters starting with A.
Use ~ to search for a literal wildcard character.
Counting blank and filled cells
=COUNTIF(A2:A100,"") blank cells
=COUNTIF(A2:A100,"<>") filled cellsCounting by date
=COUNTIF(D2:D100,">="&DATE(2026,1,1))Several conditions with COUNTIFS
Sales in London over 1,000:
=COUNTIFS(B2:B100,"London",C2:C100,">1000")All conditions must be true at once (AND logic). The ranges must be the same size or you get #VALUE!.
Finding duplicates
Use =COUNTIF($A$2:$A$100,A2)>1 in conditional formatting to highlight repeated entries.
Common problems
- Not case sensitive. "london" and "London" count as the same.
- Numbers longer than 15 digits: long codes can match wrongly; add
&"*"to the criteria or store the column as text. - Spaces: entries with trailing spaces do not match; clean them with
TRIM.
If you want totals instead of counts, see our SUMIFS guide.
Step-by-step example: counting cities and status in a customer list
Suppose column A holds the customer name, column B the city and column C the order status ("Completed", "Pending", "Cancelled"). With the formulas below you can build a small summary:
| Question | Formula |
|---|---|
| How many customers are in London? | =COUNTIF(B2:B500,"London") |
| How many orders are completed? | =COUNTIF(C2:C500,"Completed") |
| How many pending orders are in London? | =COUNTIFS(B2:B500,"London",C2:C500,"Pending") |
| Orders other than cancelled | =COUNTIF(C2:C500,"<>Cancelled") |
| Customers whose name starts with "A" | =COUNTIF(A2:A500,"A*") |
Instead of burying criteria in the formula, type them in a cell (for example "London" in F2) and use =COUNTIF(B2:B500,F2). Then you don't have to edit the formula when you change the city. If you add a drop-down list to F2 the table becomes an interactive report (see our drop-down guide).
How many of each value? A frequency table
To see how often each distinct value appears, first extract the unique values and put COUNTIF next to them. In Microsoft 365 =UNIQUE(B2:B500) builds the list automatically; in the neighbouring cell write =COUNTIF($B$2:$B$500,E2) and drag down. In older versions you can extract the unique list by hand with Data > Remove Duplicates. For fuller summaries see our pivot table guide.
Counting "between" two limits
To count values between two limits, use COUNTIFS twice on the same range:
=COUNTIFS(C2:C500,">=100",C2:C500,"<=500")This counts values from 100 to 500 inclusive. The same logic works for date ranges: write the criteria ">="&F1 and "<="&F2 side by side.
Frequently asked questions
What is the difference between COUNTIF and COUNTIFS? COUNTIF takes one condition, COUNTIFS several. You can use COUNTIFS for a single condition too; some users always write COUNTIFS to keep formulas consistent.
How do I set up an "or" condition? Add COUNTIFs: =COUNTIF(B2:B500,"Leeds")+COUNTIF(B2:B500,"York"). If one row can satisfy both conditions, take care to avoid double counting.
Can I count in a case-sensitive way? COUNTIF is case-insensitive. For case-sensitive counting use =SUMPRODUCT(--EXACT(B2:B500,"Leeds")).
Can I count a range in another workbook? Yes, but some formulas may not update while the file is closed. Keep the data in the same file where possible.
Why is the result zero? Often there is a spelling difference in the criterion, an extra space or a number stored as text. Clean the cells with TRIM and try the criterion as a cell reference (see our data cleaning guide).
Performance tips
On very large tables (hundreds of thousands of rows) use the real data range or an Excel table column (Table1[City]) instead of a full-column reference (B:B). Table references expand by themselves as data is added and don't break the formula (see our Excel tables guide).
Serkan Akyürek is the founder and author of toolrota; he writes step-by-step guides on Excel, AI, the cloud, personal finance and digital security.