Skip to content
Checkmarks hopping from a spreadsheet into a tally counter, illustrating COUNTIF

EXCEL & GOOGLE SHEETS TIPS · LESSON 5

How to Use COUNTIF in Excel and Google Sheets (Count Cells With Text)

COUNTIF counts the cells that match a condition: days a habit was done, invoices marked "Paid", trades that won, cells that contain any text at all. This lesson turns a real November habit log into a scoreboard in Excel and Google Sheets, explains the "*" trick for counting text, shows COUNTIFS for two conditions and fixes the counts that come out wrong.

6 real screenshotsExcel and Google SheetsCOUNTIF, COUNTIFS, COUNTAFree example file
Screenshots: Microsoft Excel for Mac (Microsoft 365) and Google Sheets in Chrome, taken in November 2026. COUNTIF works the same in Excel for Windows and Excel for the web.

THE SHORT ANSWER

Two arguments: where to look and what to count

=COUNTIF(C2:C31, "Yes")Count the cells in C2:C31 that say Yes. Upper or lower case doesn't matter.
EXCEL

Click the result cell → type =COUNTIF( → select the range → comma → type the condition in quotes ("Yes", ">=30", "*") or click a cell → ) → Enter.

GOOGLE SHEETS

Exactly the same: =COUNTIF(range, criterion). For several conditions in the same row use =COUNTIFS(range1, criterion1, range2, criterion2) in both apps.

The example is a habit log for November 2026: one row per day, Walk, Read and Water marked Yes or No with a drop-down list (lesson 1), green and red by conditional formatting (lesson 3), and minutes read. Days 26 to 30 are still empty, which is exactly where counting gets tricky. Download the example file (Excel; it also opens in Google Sheets).

EXCEL

How to use COUNTIF in Excel

  1. Click the result cell, J2 next to "Walk", and type =COUNTIF(.
  2. Select the range to look at, C2:C31 (the Walk column for the whole month), and type a comma.
  3. Type the criterion in quotes: "Yes". Text and comparisons always go in quotes; a cell reference doesn't.
  4. Close the bracket and press Enter. J2 shows 20: the walk was done on 20 days.
Excel habit tracker with J2 selected and the formula =COUNTIF(C2:C31,"Yes") returning 20 walk days
Done = 20 for Walk, 19 for Read, 23 for Water. Each row of the summary points at its own column.

COUNT CELLS WITH TEXT

Count cells that contain any text: the "*" criterion

A success rate needs two numbers: days done and days tracked. Days tracked are the cells with anything typed in them, Yes or No, but not the empty days at the end of the month. The asterisk is a wildcard for "any text":

=COUNTIF(C2:C31, "*")Counts every cell in C2:C31 that holds text. Empty cells and numbers are not counted. Result: 25 tracked days.
Excel cell K2 with =COUNTIF(C2:C31,"*") returning 25 tracked days and a success rate of 80 percent in L2
Tracked = 25 (Nov 1 to 25). Success rate in L2 is =J2/K2 formatted as a percentage: 20 / 25 = 80%.

Not sure what a criterion matches? Click fx next to the formula bar: the Formula Builder shows each argument and the result before you confirm.

Excel Formula Builder for COUNTIF with Range C2:C31, Criteria "*" and Result 25
COUNTIF in the Formula Builder: Range C2:C31, Criteria "*", Result 25.
FormulaCountsIn the example
=COUNTIF(C2:C31,"*")Cells with text25
=COUNTA(C2:C31)Cells that are not empty (text, numbers, errors)25
=COUNT(F2:F31)Cells with numbers only25 (minutes read)
=COUNTBLANK(C2:C31)Empty cells5 (Nov 26 to 30)
=COUNTIF(C2:C31,"?*")Text with at least one character25
"*" or "?*"? A formula that returns empty text (=IF(B2="","",…)) leaves a cell that looks blank but holds text of length zero. "*" may count those; "?*" requires at least one real character. Use "?*" when your columns are filled by formulas.

COUNTIFS

COUNTIFS: count rows that meet two conditions

"How many weekend walks?" needs two tests in the same row: the day is Saturday (or Sunday) and Walk is Yes. COUNTIFS takes pairs of range and criterion; every pair must be true. Saturday and Sunday are two separate counts added together, because one criterion can't say "Sat or Sun":

=COUNTIFS(B2:B31, "Sat", C2:C31, "Yes") + COUNTIFS(B2:B31, "Sun", C2:C31, "Yes")Result: 6 weekend walks out of 7 weekend days logged.
Excel cell J7 with a COUNTIFS formula counting Saturday and Sunday walks, returning 6
Weekend walks = 6. Above it, Read 30+ minutes uses a number criterion: =COUNTIF(F2:F31,">=30") = 6 days.

All ranges in COUNTIFS must be the same size (B2:B31 and C2:C31), or you get #VALUE!. COUNTIFS works in Excel 2007 and later and in Google Sheets.

GOOGLE SHEETS

How to use COUNTIF in Google Sheets

Type =COUNTIF( and Sheets shows the help card COUNTIF(range, criterion) with the current argument highlighted; the label above the cell previews the result (20) before you press Enter.

Google Sheets habit tracker with =COUNTIF(C2:C31,"Yes" being typed in I2, a help card and a preview of 20
Google Sheets: the same formula, the same 20 walk days.
Google Sheets cell J2 with =COUNTIF(C2:C31,"*") returning 25
"*" counts text cells in Google Sheets too: 25 tracked days.
Checkboxes instead of Yes/No? A ticked checkbox holds TRUE (in Sheets: Insert → Checkbox; in Microsoft 365 Excel: Insert → Checkbox). Count them with =COUNTIF(C2:C31, TRUE), without quotes.

COPY AND ADAPT

COUNTIF criteria cheat sheet

Count cells that…Formula
equal a word=COUNTIF(C2:C31, "Yes")
equal the value in a cell=COUNTIF(C2:C31, H2)
are not a word=COUNTIF(C2:C31, "<>No") (includes blanks)
contain a word anywhere=COUNTIF(B2:B100, "*invoice*")
start with text=COUNTIF(B2:B100, "INV-*")
are greater than or equal to a number=COUNTIF(F2:F31, ">=30")
are greater than a cell=COUNTIF(F2:F31, ">"&H1)
fall in a date range=COUNTIFS(A2:A31, ">="&DATE(2026,11,1), A2:A31, "<="&DATE(2026,11,15))
are unique values (count each once)=COUNTA(UNIQUE(FILTER(C2:C100, C2:C100<>""))) (Microsoft 365, Excel 2021+, Sheets; FILTER drops blanks, which UNIQUE would count as one more value). Google Sheets also has =COUNTUNIQUE(C2:C100).
appear more than once=COUNTIF($B$2:$B$100, B2)>1 (see lesson 7)

To add the numbers instead of counting the rows, swap in SUMIF with the same criteria: lesson 4 (SUMIF and SUMIFS).

TROUBLESHOOTING

COUNTIF not counting correctly?

What you seeWhyFix
0 for text you can seeExtra spaces ("Yes ") or a different word ("Y", "Done").Clean with TRIM; use a drop-down so entries are identical. Case doesn't matter.
"*" misses numbers"*" counts text only; 30 is a number.Use COUNTA for any non-empty cell, COUNT for numbers.
Blank-looking cells are countedFormulas returning "" or cells with a space.Use "?*" for formulas returning ""; a cell holding a space still counts, so for those use =SUMPRODUCT(--(LEN(TRIM(C2:C31))>0)).
Number criterion returns 0The cell reference is inside the quotes: ">=H1", or the numbers are stored as text.Join with &: ">="&H1; convert text numbers (Excel: Convert to Number; Sheets: VALUE).
Counts change when copied downRanges without $ slid down.Lock shared ranges: $C$2:$C$31.
#VALUE! from COUNTIFSThe ranges are different sizes.Make every range cover the same rows.
Need case-sensitive countCOUNTIF ignores case.=SUMPRODUCT(--EXACT(C2:C31,"Yes")).
Where this pays off: a habit tracker is a grid of checkboxes plus COUNTIF: done per habit, done per day, success rate and streaks. Our habit tracker template does these counts for you: checkboxes for up to 30 habits and automatic completion rates per day, week and month.

FAQ

COUNTIF questions

How do I count cells with specific text?

Use =COUNTIF(range, "text"), for example =COUNTIF(C2:C31, "Yes"). To count cells that contain the text anywhere, add asterisks: =COUNTIF(B2:B100, "*invoice*").

What is the formula to count cells with any text?

=COUNTIF(range, "*") counts every cell that contains text. Use =COUNTIF(range, "?*") if formulas return empty text, and COUNTA to count numbers as well.

How do I use COUNTIF with two conditions?

Use COUNTIFS with pairs of range and criterion: =COUNTIFS(B2:B31, "Sat", C2:C31, "Yes") counts rows where B is Sat and C is Yes. For "either/or", add two COUNTIF or COUNTIFS results.

Does COUNTIF work in Google Sheets?

Yes, with the same syntax: =COUNTIF(range, criterion). COUNTIFS, COUNTA and COUNTBLANK work too.

Is COUNTIF case-sensitive?

No. "yes", "Yes" and "YES" are all counted. For a case-sensitive count use =SUMPRODUCT(--EXACT(range, "Yes")).

How do I count non-blank cells?

Use =COUNTA(range) for any non-empty cell, or =COUNTIF(range, "<>") which counts cells that are not empty.

Back to top