COUNTIF Text: Count Cells Containing Text in Excel
In this article
To count cells that contain text, use the COUNTIF function with a wildcard: =COUNTIF(range,"*?"). The asterisk matches any number of characters and the question mark requires at least one character, so the formula counts only cells holding real text and ignores numbers, dates and blanks. In Google Sheets the same formula works unchanged. This guide covers that formula, why it is better than simpler options, and the variations you will actually need.
What You'll Need
- Excel (Microsoft 365, Excel 2021 or Excel 2019) or Google Sheets
- A column or range that mixes text with numbers, dates or empty cells
- Basic familiarity with typing a formula into a cell and pressing Enter
Step-by-Step
- Pick the range you want to inspect. Click the first cell you care about, for example A2, and note where the data ends, for example A2:A100. Keep the range tight: if you include header rows, they will be counted as text.
- Choose a clean cell for the result. Put the formula in an empty cell outside the range, such as C1, so you do not overwrite data or create a circular reference.
- Type the COUNTIF formula. Enter
=COUNTIF(A2:A100,"*?")and press Enter. The result is the number of cells containing at least one character of text in that range. - Confirm what is excluded. Numbers, dates stored as numbers, truly empty cells, and cells holding only spaces should not be counted. If your count looks higher than expected, scroll through the range for cells that look blank but contain a space or a stray character.
- Count text in multiple ranges if needed. Use two COUNTIF calls added together, e.g.
=COUNTIF(A2:A100,"*?")+COUNTIF(D2:D100,"*?"). COUNTIF accepts one range and one criterion, so this is the straightforward way to cover columns that are not adjacent. - Add up text-only totals with SUMPRODUCT for a whole block. If your data sits in a rectangular block such as A2:C100 and you want one figure, use
=SUMPRODUCT(ISTEXT(A2:C100)*1). This counts every cell containing text and ignores numbers and blanks in a single step. - Break the count down by keyword. To count cells containing a specific word, wrap it in wildcards:
=COUNTIF(A2:A100,"*shipped*"). The asterisks on both sides mean the text can appear anywhere in the cell. - Make the keyword variable. Put the search word in its own cell, say E1, and use
=COUNTIF(A2:A100,"*"&E1&"*"). Change E1 and the count updates without editing the formula. - Check against a manual sample. Select a few cells in the range and visually confirm they are the kind of content you expect. If the total disagrees, the usual causes are hidden spaces, number-as-text values, or merged cells.
- Extend with COUNTIFS for extra conditions. If each row also has a status in column B,
=COUNTIFS(A2:A100,"*?",B2:B100,"Open")counts text values still marked Open. - Save and test edge cases. Add a numeric value and a blank row to the range and confirm the count does not change. If it does, your formula or range needs adjusting.
Common Mistakes
Using "*". A lone asterisk is meant to match any length, but many people expect it to mean text only. Use "*?" when you want to require at least one character.
Including headers and totals. A header cell that reads "Name" is text and will be counted. Start ranges at the first data row and stop before any totals row.
Mixing data types. Dates typed as text and numbers stored as text look identical on screen. Use ISNUMBER or ISTEXT checks or filter the column by data type if a count feels wrong.
Forgetting hidden spaces. A cell with a single space is technically text. TRIM or a filter helps reveal them.
Editing the range by dragging. Dragging a formula with a relative range shifts the range down with each row. Lock it with dollar signs, e.g. $A$2:$A$100, when copying it.
Tips
Name your range (Formulas > Name Manager in Excel) so formulas read clearly, such as =COUNTIF(Shipments,"*?"). That path is standard in desktop Excel; the wording may vary slightly by version and region.
Use a small helper column with =ISTEXT(A2) when you want to audit exactly which cells are being counted. TRUE and FALSE next to each row make mistakes obvious.
To count cells that do not contain text, subtract from the range size: =ROWS(A2:A100)-COUNTIF(A2:A100,"*?").
Wildcards do not work in all contexts, and you can search for a literal asterisk with a tilde: "~*".
Troubleshooting
If the formula returns 0, check the range reference. A common cause is a space or typo in the range, or the data sitting on a different sheet. Click the range reference in the formula bar and confirm Excel highlights the correct cells.
If the formula returns an error, suspect a missing quotation mark or a mixed quote style. Also ensure you did not type smart quotes from a document editor; Excel expects straight quotes.
If the count is too high, look for cells with spaces, apostrophes leading numbers, or formulas returning empty strings. Filter the column and scroll to the bottom; trailing spaces often hide there.
If the count is too low, check for merged cells and hidden rows. Hidden rows are still counted, but filtered-out rows in a normal COUNTIF are included too, so do not assume the number reflects only visible rows.
If the number keeps changing, check for volatile formulas or external links in the range. A workbook recalculating on open can briefly shift results.
Frequently Asked Questions
What is the difference between COUNTIF("*") and COUNTIF("*?")?
Both are intended to match text, but "*?" requires at least one character, which is the safe choice for counting cells that actually contain text.
Does COUNTIF count numbers stored as text?
Yes. If a number was entered or imported as text, the wildcard sees it as text and counts it. Clean those values first if you need a pure text count.
Can I count text in two different columns at once?
Not with a single COUNTIF in the usual way. Add two COUNTIF formulas together or use SUMPRODUCT with ISTEXT across the block.
Why does COUNTIF include blank-looking cells?
They contain a character such as a space or an apostrophe, or a formula returning an empty string. TRIM the column or inspect the cell contents.
Does this work in Google Sheets?
Yes. Enter the same formula, for example =COUNTIF(A2:A100,"*?"), and press Enter. Google Sheets treats wildcards in COUNTIF the same way.
Can I count cells containing a specific word?
Yes. Put the word in its own cell and build the criterion with ampersands, such as =COUNTIF(A2:A100,"*"&E1&"*"), so the formula stays reusable.