Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

COUNTIF Criteria in Excel: How to Use It Correctly

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

COUNTIF counts how many cells in a range meet a condition you define. You type the range, then a criterion in quotes: =COUNTIF(A2:A100,"North") returns how many cells in that range contain exactly North. The criterion is where most people stumble, because Excel treats text, numbers, wildcards, cell references and operators differently, and the right syntax depends on which of those you use. Get the criterion right and COUNTIF handles exact matches, partial matches, comparisons, blanks and duplicates without any sorting or filtering.

What You'll Need

  • Excel on desktop (Microsoft 365, Excel 2021, 2019 or 2016) or Excel for the web. Excel for iPhone and Android supports COUNTIF but editing long formulas on a phone is slow, so use a computer if you can.
  • A data range with a single header row and no blank rows in the middle, since blanks break COUNTIF selections less than they break tables but still cause confusion.
  • A clear idea of what you are counting: exact text, a partial word, numbers above or below a threshold, dates inside a month, or empty cells.
  • Optional but useful: a small helper area holding your criteria so you can change them without editing the formula.

Step-by-Step

  1. Pick an empty cell for the result. Never put COUNTIF inside the range it counts, or a circular reference error appears.
  2. Start the formula. Type =COUNTIF(. Excel will show a tooltip naming the two arguments, range and criteria. Menu and tooltip wording can differ slightly between versions, but the function itself is unchanged.
  3. Select the range. Drag over the data, or type it, and press F4 to lock it (for example $A$2:$A$500) if you plan to copy the formula down. Locked references prevent the range drifting as you fill.
  4. Type a comma, then build the criterion. This is the part that decides whether the formula works. Use the patterns in the next step according to what you are counting.
  5. Choose the criterion pattern:
    • Exact text: =COUNTIF(A2:A100,"North"). Text criteria are not case-sensitive, so North and north both match.
    • Comparison: =COUNTIF(B2:B100,">500") or "<=100". The operator and number live together inside the quotes.
    • Comparison against a cell: =COUNTIF(B2:B100,">"&D1). The operator stays in quotes, then an ampersand joins it to the cell reference which stays outside quotes.
    • Partial text with wildcards: =COUNTIF(A2:A100,"*inc*") counts any cell containing inc. The question mark matches one character, so "A?c" finds Abc and Axc but not Abbc.
    • Literal wildcard characters: put a tilde in front, as in "~*" to count cells containing an actual asterisk.
    • Blanks and non-blanks: "" counts empty cells, "<>" counts non-empty ones.
    • Not equal to a word: "<>North".
  6. Close the bracket and press Enter. The cell shows a count. If it shows a formula instead of a result, the cell is formatted as Text; set the format to General and re-enter the formula.
  7. Verify against a quick manual check. Apply an AutoFilter to the column and look at the status bar count, or filter to the same value and read the row number. This catches wildcard and operator mistakes before they spread through a workbook.
  8. Copy the formula where needed. Keep the range absolute, and leave the criteria cell relative if you are comparing against different thresholds in a list.

Common Mistakes

  • Forgetting the quotes around text. =COUNTIF(A:A,North) produces a #NAME? error because Excel reads North as an undefined name.
  • Putting a number comparison in quotes without the operator joined properly. ">"D1 is invalid; it must be ">"&D1.
  • Expecting COUNTIF to handle more than one condition. It accepts exactly one range and one criterion. Two conditions require COUNTIFS with paired ranges and criteria, or you add two COUNTIF results together.
  • Assuming it is case-sensitive. It is not. Use SUMPRODUCT with EXACT if case matters.
  • Counting long text wrongly. COUNTIF compares text of more than 255 characters unreliably and can return a wrong count; the safer route for long strings is SUMPRODUCT with an equality test.
  • Quoting numbers as text. If your column holds numbers stored as text, ">500" behaviour becomes unpredictable. Convert the column to real numbers first.

Tips

  • Keep criteria in cells and reference them. A dashboard where you type a threshold in one cell and every COUNTIF follows it is far easier to maintain than editing dozens of formulas.
  • Use whole-column references like A:A for simple sheets, but restrict ranges on large workbooks; whole-column COUNTIF over hundreds of thousands of rows can slow recalculation.
  • Pair COUNTIF with conditional formatting, using the formula =COUNTIF($A$2:$A$100,$A2)>1 to highlight duplicates, or use the built-in duplicate rule if you only need highlighting.
  • Watch for trailing spaces. "North " and "North" do not match. TRIM the column or clean the source data.
  • Combine wildcards for ranges of text, for example "[A-M]*" counts entries starting with letters in that bracket set.
  • Remember that COUNTIF ignores cells containing errors when you count text but can behave oddly if errors sit inside the range you are testing; clean them first.

Troubleshooting

The result is 0 when you expect more. Check for stray spaces, numbers stored as text, or a criterion that is too strict. Wildcards do not match numbers unless the numbers are text, so counting a numeric column with "1*" will not work. Also check whether the value is a date formatted to look like text; dates need a real date criterion such as ">="&DATE(2025,1,1).

You get #VALUE! or #NAME?. The quotes are in the wrong place, an operator is missing, or the range argument is malformed. Rebuild the formula argument by argument and confirm the comma separating range from criterion is present.

Counts look doubled. Your range may overlap two copies of the same data, or you are counting a filtered list and expecting only visible rows. COUNTIF counts hidden and filtered-out rows too; use SUBTOTAL with function number 103 for visible-row counting instead.

It works on desktop but errors on another machine. That usually means a regional list separator: some regions use a semicolon instead of a comma between arguments. Excel for the web generally adapts automatically, but copied formulas can carry the wrong separator. Check your Windows region settings for the list separator value.

The formula will not recalculate. Set calculation to Automatic under the Formulas tab, or press F9 to force a calculation. If the workbook was saved with manual calculation on, every COUNTIF result stays stale until you recalc.

Frequently Asked Questions

Is COUNTIF case-sensitive?

No. North, north and NORTH all match. For case-sensitive counting, use SUMPRODUCT with EXACT.

Can COUNTIF use two or more criteria?

Not in one function. Use COUNTIFS with the same number of ranges and criteria, or add separate COUNTIF results together.

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

Wrap it in asterisks, for example *word*. To match the whole cell only, drop the asterisks.

How do I count dates within a month or year?

Use a lower and upper bound joined to dates: >="&DATE(2025,1,1) and "<="&DATE(2025,1,31), either as two COUNTIFS criteria or two COUNTIF results added.

Can COUNTIF count blank cells?

Yes, with "" as the criterion. Use caution with cells holding empty strings from formulas, which may not count as truly blank.

Does COUNTIF work the same in Google Sheets?

The syntax and wildcard behaviour are very similar, though a few edge cases differ. Test a complex criterion before relying on it across both programs.