FormulaCraft

Fix the COUNTIF error

Excel & Google Sheets
Topic:COUNTIF & COUNTIFS

What COUNTIF means

COUNTIF 'not working' usually means it returns 0 when matches are expected, returns a wrong count, or shows a #VALUE! error. The formula itself is rarely broken — the problem is almost always a mismatch between how data is stored and how the criteria is written.

Common causes

Example fix

Broken
=COUNTIF(A2:A100,>0)
Fixed
=COUNTIF(A2:A100,">0")

The comparison operator must be inside a quoted string. Without quotes, the formula either errors or compares incorrectly depending on the spreadsheet version.

Try it with your data

Edit the grid or formula, then run it through a real spreadsheet engine — no signup.

Sample data — click any cell to edit

Runs server-side · free · no signup

How to fix it

  1. 1Quote all comparison operators: =COUNTIF(A:A,">5") or =COUNTIF(A:A,"<>0"). Use & to combine with a cell reference: =COUNTIF(A:A,">"&B2).
  2. 2Accept that COUNTIF is case-insensitive. For case-sensitive counting, use SUMPRODUCT: =SUMPRODUCT((EXACT(A2:A100,"Apple"))*1).
  3. 3Audit the range for mixed types with =ISNUMBER(A2) in a helper column. Separate numeric and text counting, or standardise the data.
  4. 4To count literal asterisks or question marks, escape them with a tilde: =COUNTIF(A:A,"~*") counts cells that literally contain *.
  5. 5Double-check the range reference by clicking the formula cell and observing the coloured range highlight, or type the range manually rather than clicking.

Stop hunting errors by hand.

Upload your spreadsheet and the Auditor flags every COUNTIF and broken formula at once — or paste this one formula and get the fix explained.

Frequently asked

Does COUNTIF count blank cells?

Yes. Use =COUNTIF(A:A,"") to count truly empty cells. Note that cells with a formula that returns "" are counted as blank by COUNTIF.

How do I count cells that contain a specific word anywhere in the text?

Use a wildcard: =COUNTIF(A:A,"*budget*") counts any cell in column A that contains the word 'budget' anywhere in the string.

COUNTIF is counting cells I do not want — how do I add a second condition?

COUNTIF only supports one condition. Switch to COUNTIFS which accepts multiple criteria_range/criteria pairs, all evaluated with AND logic.

More on COUNTIF & COUNTIFS

See all →

Related formulas

Written and reviewed by FormulaCraft Team. Each formula on this page is run through our verification engine before publishing.

Last reviewed: