COUNTIF with a cell reference: how to write the criteria
Updated · Checked on a live sheet · Excel and Google Sheets
The most likely fix
Put only the operator in quotes and join the cell with &: COUNTIF(F2:F13, ">="&K1). For an exact match, use the cell on its own with no quotes at all: COUNTIF(C2:C13, K1).
Fix it yourself
The formula in K2 shows the problem. Edit it to the fixed version and watch the sheet recalculate.
| A | B | C | D | E | F | G | H | I | J | K | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Order | Date | Customer | Product | Category | Qty | Price | Status | At least | 3 | |
| 2 | 1001 | 2 Mar 2026 | Mara Okafor | Monstera | Plants | 1 | $34.00 | Shipped | Orders | 0 | |
| 3 | 1002 | 2 Mar 2026 | Jonas Lind | Terracotta pot | Pots | 3 | $12.50 | Shipped | |||
| 4 | 1003 | 3 Mar 2026 | Priya Raman | Snake plant | Plants | 2 | $22.00 | Shipped | |||
| 5 | 1004 | 4 Mar 2026 | Tomás Ruiz | Watering can | Tools | 1 | $18.00 | Pending | |||
| 6 | 1005 | 5 Mar 2026 | Elif Demir | Fern | Plants | 4 | $9.50 | Shipped | |||
| 7 | 1006 | 5 Mar 2026 | Mara Okafor | Potting mix | Soil | 2 | $7.25 | Returned | |||
| 8 | 1007 | 6 Mar 2026 | Kenji Mori | Pruning shears | Tools | 1 | $24.00 | Shipped | |||
| 9 | 1008 | 7 Mar 2026 | Ines Varga | Ceramic pot | Pots | 2 | $19.00 | Pending | |||
| 10 | 1009 | 8 Mar 2026 | Jonas Lind | Monstera | Plants | 1 | $34.00 | Shipped | |||
| 11 | 1010 | 9 Mar 2026 | Sofia Rossi | Fern | Plants | 6 | $9.50 | Shipped | |||
| 12 | 1011 | 10 Mar 2026 | Priya Raman | Potting mix | Soil | 5 | $7.25 | Shipped | |||
| 13 | 1012 | 11 Mar 2026 | Leo Brandt | Snake plant | Plants | 1 | $22.00 | Pending |
Shows the problem
=COUNTIF(F2:F13,">=K1")Fixed
=COUNTIF(F2:F13,">="&K1)Causes, most likely first
1The operator and the reference are both in quotes
">=K1"asks COUNTIF to compare each quantity with the letters K1. Nothing matches, so the count is 0. Join the operator to the cell:">="&K1counts orders with at least the quantity in K1.Wrong
=COUNTIF(F2:F13,">=K1")Fixed
=COUNTIF(F2:F13,">="&K1)2Quotes around a plain cell reference
For “equal to the value in K1”, the criteria is just
K1."K1"in quotes counts cells that contain the text K1. Microsoft's COUNTIF page lists a cell like B4 as a valid criteria next to a number, a comparison and a word.Wrong
=COUNTIF(C2:C13,"K1")Fixed
=COUNTIF(C2:C13,K1)3A “contains” search from a cell
Wildcards go in quotes on each side of the joined cell:
"*"&K1&"*"counts cells containing the text in K1 anywhere. Both Microsoft and Google document*(any run of characters) and?(one character), with~before them to match a literal asterisk or question mark.Wrong
=COUNTIF(D2:D13,"*K1*")Fixed
=COUNTIF(D2:D13,"*"&K1&"*")4The count is right but surprising
COUNTIF ignores case, so “mara” and “MARA” count as the same (Microsoft's page says criteria aren't case sensitive). And a criteria longer than 255 characters gives wrong results; Microsoft suggests splitting it with
&.5Counting blanks and non-blanks
Two criteria trip people up because they look empty.
"<>"counts non-empty cells and""counts empty ones; neither needs a cell reference. For “not equal to the value in K1”, join the operator:"<>"&K1; written inside the quotes,"<>K1"counts every cell that isn't the text K1, which is nearly all of them.Wrong
=COUNTIF(C2:C13,"<>K1")Fixed
=COUNTIF(C2:C13,"<>"&K1)
Stop it happening again
Keep criteria values in cells and write the test once with &; that turns a COUNTIF into a small control panel anyone can change without editing formulas. Use quotes only for the parts that are literally text: the operator, a fixed word, wildcards. When a count looks wrong, put the criteria text in a cell of its own, for example =\">=\"&K1, to see exactly what COUNTIF receives. And remember COUNTIF ignores case: for a case-sensitive count use SUMPRODUCT(--EXACT(range, K1)).
Questions
Can COUNTIF use a range of criteria?
Yes: give it a range as the criteria and, in Excel 2021 or later and Microsoft 365, it spills one count per criteria value, for example COUNTIF(C2:C13, K1:K3). To add them up into one number, wrap it in SUM. In older versions, use one COUNTIF per value.
How do I count cells greater than a value in another cell?
COUNTIF(F2:F13, ">"&K1). The operator goes in quotes, the cell reference outside, joined with &. The same works for <, >=, <= and <>.
Why does COUNTIF with a date in a cell return 0?
Because of the same quotes rule: ">="&K1 works with a real date in K1. If K1 holds a date typed as text, or the column's dates are text, the comparison never succeeds; check both with ISNUMBER. A date written inside the criteria is safest built with DATE: ">="&DATE(2026,3,1).
In Google Sheets
Google Sheets' COUNTIF reads criteria the same way: a string criterion must be in quotes, comparisons go inside the quotes, & joins a cell, and its help documents the same ?, * and ~ wildcards. Every fix on this page works there unchanged.
Why this happens
COUNTIF's criteria argument is a piece of text that describes a test. A cell reference inside that text is just letters; only outside the quotes is it a reference. Building the test with & lets one formula follow whatever you type into K1, which is what makes a small dashboard work. The SUMIFS guide uses exactly the same criteria rules, and find duplicates uses COUNTIF with a reference to each row.
Sources
Official documentation the facts on this page were checked against.