July 13, 2026

COUNTIF in Excel: Count Cells by Criteria, with Examples

Convert a PDF to Excel right here, no sign-up to try:

Drop your PDF here or click to browse

PDF files up to 50MB

Uploading...

First file free. Files are deleted after processing.

COUNTIF counts how many cells in a range meet one condition, with this syntax: =COUNTIF(range, criteria). So =COUNTIF(B2:B500, "Fuel") counts every cell in that range equal to Fuel, and =COUNTIF(C2:C500, ">100") counts every value over 100. The criteria goes in quotation marks whenever it contains text or a comparison operator. That single function answers most "how many" questions you have about a column of converted data.

The reason it matters after a conversion is verification. You turn a PDF statement or report into Excel and you want to know how many transactions came from one vendor, how many amounts exceed a threshold, or how many rows are blank because the extraction dropped them. COUNTIF gives you each answer in one formula, and the count is also a fast way to catch data that came in wrong.

The two arguments

ArgumentWhat it meansExample
rangeThe cells you want Excel to look throughB2:B500
criteriaThe condition a cell must meet to be counted"Fuel", ">100", ">="&E1

Criteria is where people trip. A plain number needs no quotes: =COUNTIF(C2:C500, 100). Text and any operator need quotes: "Fuel", ">100", "<>0" for not equal to zero. And when the condition points at another cell, you join the operator to the cell with an ampersand: =COUNTIF(C2:C500, ">"&E1) counts everything greater than whatever sits in E1. Forgetting the ampersand is the most common reason a cell-based criterion returns zero.

A worked example

Say you converted three months of a card statement into Excel and landed with the merchant in column A, the category in column B, and the amount in column C, running from row 2 to row 480. You want a quick summary before you reconcile anything. In a spare cell you write =COUNTIF(B2:B480, "Travel") and get the number of travel charges. Next to it, =COUNTIF(C2:C480, ">500") tells you how many single charges topped 500 dollars, the ones worth eyeballing for errors. And =COUNTIF(A2:A480, "*uber*") counts every ride-share line regardless of how the merchant name was spelled out. Three formulas, and you know the shape of the statement before you touch a single row.

How do I count cells with specific text?

For an exact match, put the text in quotes: =COUNTIF(A2:A500, "Paid"). COUNTIF is not case sensitive, so "Paid", "paid", and "PAID" all count together. For a partial match, use wildcards: =COUNTIF(A2:A500, "*fuel*") counts any cell that contains the word fuel anywhere, and =COUNTIF(A2:A500, "INV*") counts cells that start with INV. The asterisk stands for any run of characters and a question mark stands for a single character, so "?????" counts cells with exactly five characters.

How do I count with two conditions?

Switch to COUNTIFS, which takes range and criteria pairs and counts only rows that satisfy all of them: =COUNTIFS(A2:A500, "Fuel", C2:C500, ">100") counts fuel transactions over 100. Every range in a COUNTIFS has to be the same height or Excel returns a #VALUE! error. COUNTIFS is an AND test by row. To count rows matching one condition OR another, add two COUNTIF results together: =COUNTIF(A2:A500, "Fuel") + COUNTIF(A2:A500, "Parking").

How do I count dates in a range?

Treat dates like numbers and join the operator to the boundary with an ampersand. To count entries in one month, use two conditions: =COUNTIFS(D2:D500, ">="&DATE(2026,1,1), D2:D500, "<="&DATE(2026,1,31)). This works only when the cells hold real dates. If the dates came out of the PDF as text, the count comes back at zero, and you need to fix the date format first so Excel treats them as dates.

COUNTIF, COUNTA, COUNT, and COUNTBLANK

Four related functions answer different questions, and picking the wrong one is a quiet source of wrong totals.

FunctionCounts
COUNTIFCells that meet a condition
COUNTCells that contain numbers only
COUNTACells that are not empty (numbers or text)
COUNTBLANKCells that are empty

The gap between COUNT and COUNTA is a useful check on converted data. If COUNTA on your amount column is higher than COUNT, some amounts are stored as text rather than numbers, which is the same problem that makes a column refuse to sum. That mismatch tells you to clean the column before you trust any total.

Why is my COUNTIF returning 0?

COUNTIF returns zero when nothing in the range matches the criteria as written, and after a conversion there are three usual reasons. First, the value you are counting is stored as text while your criteria is a number, or the reverse, so they never match; fix the type with our guide to converting text to numbers. Second, trailing spaces: "Fuel " with a space on the end does not equal "Fuel", so remove the extra spaces first. Third, a cell-based criterion missing its ampersand, like ">E1" in quotes, which searches for the literal text rather than the value in E1.

How do I count unique values?

COUNTIF has no dedicated unique option, but two approaches get you there. On Microsoft 365 or Excel 2021, wrap the modern UNIQUE function in COUNTA: =COUNTA(UNIQUE(A2:A500)) returns the number of distinct entries in the column. On older versions, use the reciprocal-count trick =SUMPRODUCT(1/COUNTIF(A2:A500, A2:A500)), which adds a fraction for each duplicate so every value contributes exactly one to the total. Note the second version breaks if the range holds any blank cells, so trim the range to the filled rows first. A unique count is the fast way to answer how many different vendors, accounts, or item codes appear in a statement you just converted.

Counting only the rows you can see

COUNTIF counts hidden and filtered rows too, which surprises people who have applied a filter. To count only visible rows, use SUBTOTAL: =SUBTOTAL(3, A2:A500) counts visible non-empty cells and updates as you change the filter. That is the version you want when you are spot checking a filtered slice of a converted statement rather than the whole sheet.

Using COUNTIF to check a conversion pulled every row

A count is the cheapest audit you can run on freshly converted data. If the original PDF statement listed 312 transactions, then =COUNTIF(A2:A1000, "<>") should return 312 for a column that is always filled, such as the date or the amount. Anything lower means the extraction dropped rows, and the gap tells you exactly how many to hunt for. Pair it with =COUNTBLANK(C2:C313) on the amount column to find rows that came through with a missing figure. Doing this before you total anything saves you from signing off on a report that is quietly short a page.

Where COUNTIF fits in a conversion workflow

Once you convert the PDF to Excel, COUNTIF is your first sanity pass. Count the rows to confirm the extraction pulled every line, count each vendor to see the mix, and count blanks to find gaps. From there you can total each category with SUMIF and, when the books are ready, roll the clean figures into a finished financial statement. The count comes first because a total you trust starts with a row count that matches the source document.

The short version

Use =COUNTIF(range, criteria), quote any text or operator, and join a cell-based condition with an ampersand. Move up to COUNTIFS for two or more conditions, and use SUBTOTAL when you only want the visible rows. If COUNTIF returns zero on converted data, the criteria is almost always fine and the data is not: check for numbers stored as text and stray spaces before you rewrite the formula.