Cellwise Start free

Excel guide · 5 min read

COUNTIFS not working: why it returns 0 or #VALUE!

Quick answerCOUNTIFS returns #VALUE! when its ranges are different sizes, so make every range cover the same rows. It returns 0 or too low a count when a criterion is written as ">H2" instead of ">"&H2, when cells have trailing spaces, when dates or numbers are stored as text, when you use wildcards on numbers, or when you expect two criteria on the same column to mean OR.

Sample data

Every result on this page was calculated from this sheet by the same spreadsheet engine the Cellwise app uses.

ABCDEFGH
1TicketAgentStatusOpenedHoursOrder noMin hours
2T-1001AnaOpenOct 2, 20263.5104825
3T-1002BenClosedOct 6, 2026810517
4T-1003AnaOpen Oct 9, 2026610533
5T-1004CaraOpen2026-10-141220114
6T-1005BenOpen Oct 20, 2026210560
7T-1006AnaClosed10/23/20269.520131
8T-1007CaraOpenOct 27, 2026710602
9T-1008BenOpenNov 2, 2026420150

Download this sheet as an Excel practice file (.xlsx)

#VALUE!: the ranges are different sizes

Every criteria range in COUNTIFS must have the same number of rows and columns. COUNTIFS checks row 1 of each range together, then row 2, and so on, so B2:B9 and C2:C10 cannot be paired up. Excel refuses with #VALUE! rather than guess.

It usually creeps in when you edit one range after adding data, or click a range with the mouse and grab an extra row. Press F2 on the cell and compare the coloured boxes. Converting the data to a table (Ctrl+T) and using column names keeps all the ranges the same length as rows are added.

COUNTIFS also returns #VALUE! when it points at another workbook that is closed. Open the source file, or move the data into the same workbook.

=COUNTIFS(B2:B9,"Ana",C2:C10,"Open")

Result: #VALUE!

#VALUE!, because B2:B9 has 8 rows and C2:C10 has 9. Make both end on row 9.

0: the criterion compares against the text ">H2"

You want tickets that took more than the hours in H2 (5). Writing ">H2" in quotes makes it plain text, so COUNTIFS looks for values greater than the letters H2, finds none among the numbers, and returns 0 with no error.

Keep the operator in quotes and join the cell reference with &: ">"&H2. The same goes for dates and functions: ">="&DATE(2026,10,1) or "<"&TODAY(). A criterion without a cell, such as ">5", stays entirely inside the quotes. Leaving the quotes off (>5 on its own) is a syntax error and Excel will not accept the formula.

=COUNTIFS(E2:E9,">"&H2)

Result: 5

5 tickets took more than 5 hours. The same formula with ">H2" returns 0.

Hidden trailing spaces

There are six open tickets, but =COUNTIFS(C2:C9,"Open") returns 4. Two status cells actually hold "Open " with a space at the end, which is common in exports and pasted data. To COUNTIFS "Open " and "Open" are different values. Check with =LEN(C4): it returns 5 for a four-letter word.

The quick fix is a wildcard, "Open*", which matches Open followed by anything. That is fine here, but it would also count "Opened" or "Open - waiting". The proper fix is to clean the column: put =TRIM(C2) in a helper column, fill down, and paste it back as values. COUNTIFS cannot apply TRIM itself; if you cannot change the data, use SUMPRODUCT, which can: =SUMPRODUCT((B2:B9="Ana")*(TRIM(C2:C9)="Open")) also gives 2.

=COUNTIFS(B2:B9,"Ana",C2:C9,"Open*")

Result: 2

2 open tickets for Ana. With "Open" and no wildcard it returns 1, because T-1003 is "Open ".

Dates stored as text are skipped

Counting October tickets with a date range should give 7, but the formula below returns 5. Two dates in column D came in as text ('2026-10-14 and '10/23/2026). They look like dates, but a comparison such as ">="&DATE(2026,10,1) only counts real numbers, so text dates are silently left out.

Spot them with =COUNT(D2:D9), which returns 6 for 8 rows: two cells are not numbers. =SUMPRODUCT(--ISTEXT(D2:D9)) counts them directly (2). Text dates usually sit on the left of the cell. Convert the column with Data > Text to Columns, or with DATEVALUE in a helper column, and the count becomes 7.

=COUNTIFS(D2:D9,">="&DATE(2026,10,1),D2:D9,"<"&DATE(2026,11,1))

Result: 5

5, not 7: the two October dates stored as text are not counted.

Wildcards do not match numbers

Order numbers starting with 10 belong to the online store. =COUNTIFS(F2:F9,"10*") looks right but returns 1. Wildcards (* and ?) only match text, so the real numbers 10482, 10517, 10560 and 10602 are ignored. The one match is F4, an order number stored as text.

For whole numbers in a known range, use two numeric criteria instead: =COUNTIFS(F2:F9,">=10000",F2:F9,"<20000") gives 4, which still misses the text one. To catch numbers and text together, test the first characters with SUMPRODUCT and LEFT, which treats every value as text.

=SUMPRODUCT(--(LEFT(F2:F9,2)="10"))

Result: 5

5 orders start with 10, including the one stored as text. COUNTIFS with "10*" finds only 1.

Two criteria on one column means AND, not OR

COUNTIFS counts rows where every condition is true at once. =COUNTIFS(B2:B9,"Ana",B2:B9,"Ben") asks for rows where the agent is Ana and also Ben, which is impossible, so the answer is 0. Using the same range twice only makes sense for between conditions, such as ">=10000" and "<20000".

For OR, give COUNTIFS an array constant of the values and wrap it in SUM. Each value is counted separately and SUM adds the counts. The other criteria still apply to both: =SUM(COUNTIFS(B2:B9,{"Ana","Ben"},C2:C9,"Open*")) gives 4 open tickets for Ana or Ben. Adding two COUNTIFS with + does the same thing and is easier to read when there are only two values.

=SUM(COUNTIFS(B2:B9,{"Ana","Ben"}))

Result: 6

6 tickets: 3 for Ana plus 3 for Ben. The AND version returns 0.

Common mistakes

Range sizes that do not match

Every criteria range must cover the same rows, such as B2:B9 and C2:C9. A mismatch gives #VALUE!. Use an Excel table so ranges grow together.

Putting the cell reference inside the quotes

">H2" is literal text. Write ">"&H2, and the same for dates: ">="&DATE(2026,10,1).

Trusting a count from imported data

Check for trailing spaces with LEN and for text numbers or dates with COUNT against the row count. Clean the column with TRIM or Text to Columns before counting.

Expecting COUNTIFS to be case-sensitive

"open" and "Open" count the same. For a case-sensitive count use SUMPRODUCT with EXACT.

FAQ

Why is my COUNTIFS returning 0?

The most common causes are a cell reference written inside the quotes (">H2" instead of ">"&H2), hidden spaces in the data, dates or numbers stored as text, or two criteria on one column that can never both be true. Test each criterion on its own with COUNTIF to find which one fails.

Why does COUNTIFS give #VALUE!?

The criteria ranges are different sizes, for example B2:B9 and C2:C10, or the formula refers to a closed workbook. Make every range cover exactly the same rows.

How do I use OR logic in COUNTIFS?

Wrap it in SUM with an array constant: =SUM(COUNTIFS(B2:B9,{"Ana","Ben"})). Or add two COUNTIFS together. Several criteria in one COUNTIFS always mean AND.

Can COUNTIFS use a wildcard with numbers?

No. Wildcards only match text. Use number comparisons such as ">=10000" and "<20000", or SUMPRODUCT with LEFT to test the leading digits.

Why does COUNTIFS not count some of my dates?

Those dates are probably text. COUNT on the column will be lower than the row count. Convert them with Data > Text to Columns or DATEVALUE, and COUNTIFS will include them.

Functions used

Related guides

Updated