formulastreak

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.

">=K1" is the text “>=K1”, not a comparison with K1 · edit K2 and watch it recalculate
Click a cell (or use the arrow keys) to insert its address · Enter shows the resultK2 = 0
ABCDEFGHIJK
1OrderDateCustomerProductCategoryQtyPriceStatusAt least3
210012 Mar 2026Mara OkaforMonsteraPlants1$34.00ShippedOrders0
310022 Mar 2026Jonas LindTerracotta potPots3$12.50Shipped
410033 Mar 2026Priya RamanSnake plantPlants2$22.00Shipped
510044 Mar 2026Tomás RuizWatering canTools1$18.00Pending
610055 Mar 2026Elif DemirFernPlants4$9.50Shipped
710065 Mar 2026Mara OkaforPotting mixSoil2$7.25Returned
810076 Mar 2026Kenji MoriPruning shearsTools1$24.00Shipped
910087 Mar 2026Ines VargaCeramic potPots2$19.00Pending
1010098 Mar 2026Jonas LindMonsteraPlants1$34.00Shipped
1110109 Mar 2026Sofia RossiFernPlants6$9.50Shipped
12101110 Mar 2026Priya RamanPotting mixSoil5$7.25Shipped
13101211 Mar 2026Leo BrandtSnake plantPlants1$22.00Pending

Shows the problem

=COUNTIF(F2:F13,">=K1")

Fixed

=COUNTIF(F2:F13,">="&K1)

Causes, most likely first

  1. 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: ">="&K1 counts orders with at least the quantity in K1.

    Wrong

    =COUNTIF(F2:F13,">=K1")

    Fixed

    =COUNTIF(F2:F13,">="&K1)
  2. 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)
  3. 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&"*")
  4. 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 &.

  5. 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.

Practise this in 5 minutes

COUNTIF is taught in Lesson 18: SUMIF and criteria (Unit 5, Conditional totals), on a live sheet with instant feedback. Pro

Open “SUMIF and criteria”

Get the formulastreak newsletter

Bite-sized formula tips you can use at work the next day, plus a heads-up when new free tools and lessons land. It arrives now and then, never in a flood.

No spam, unsubscribe in one click. We store your email, this consent and when you gave it. Details in our privacy policy.

Need a quick reference? The formula cheat sheet is free to read and print.