To count how many cells contain text in Excel, use the COUNTIF function with a wildcard or combine ISTEXT with SUMPRODUCT. These methods count cells that hold any textual value, ignoring numeric entries and blank cells.
What You’ll Need
- Microsoft Excel (any recent version)
- A worksheet with data you want to analyze
- Basic familiarity with formulas and cell references
Step‑by‑Step
- Open your worksheet. Navigate to the sheet that contains the data range you wish to evaluate.
- Decide on the range. For example, if your data occupies cells A1 through A20, that will be the reference for the formula.
- Choose a counting method. Two common approaches are:
- COUNTIF with a wildcard:
=COUNTIF(A1:A20,"*"). This counts any cell that contains at least one character, including numbers stored as text. - SUMPRODUCT with ISTEXT:
=SUMPRODUCT(--ISTEXT(A1:A20)). This counts only cells that Excel recognises as text, excluding numeric values and blanks.
- COUNTIF with a wildcard:
- Enter the formula. Click an empty cell where you want the result to appear, type the chosen formula, and press Enter.
- Verify the result. The cell should display a number equal to the count of text‑containing cells. If it shows
0or an error, proceed to troubleshooting. - Use named ranges for clarity. If your data is in an Excel Table named
MyTable, the formula becomes=COUNTIF(MyTable[Column],"*")or=SUMPRODUCT(--ISTEXT(MyTable[Column])). - Apply the formula to multiple columns. To count text across two columns, use
=SUMPRODUCT(--ISTEXT(A1:A20),--ISTEXT(B1:B20))or combine COUNTIFs:=COUNTIF(A1:A20,"*")+COUNTIF(B1:B20,"*"). - Leverage dynamic arrays. In Excel 365, use
=FILTER(A1:A20, ISTEXT(A1:A20))to list all text entries, then wrap withCOUNTAto count them:=COUNTA(FILTER(A1:A20, ISTEXT(A1:A20))). - Consider trimming spaces. If cells may contain only spaces, add
TRIMto the condition:=SUMPRODUCT(--ISTEXT(TRIM(A1:A20)))to exclude cells that appear blank but contain spaces. - Save your workbook. After verifying the count, save the file to preserve the formula and results.
Common Mistakes
- Using
COUNTAalone, which counts numbers as well as text. - Applying
COUNTIFwith an empty string ("") instead of a wildcard, which counts only truly blank cells. - Referencing the wrong range or mixing relative and absolute references, causing the formula to count unintended cells.
- Ignoring cells that contain spaces; these are counted as text unless trimmed.
- Not accounting for hidden rows or filtered data;
COUNTIFcounts hidden cells unlessSUBTOTALis used. - Using
ISTEXTwithout the double unary (--), which returns an array that Excel may not evaluate correctly.
Tips
- Use
SUBTOTAL(103, A1:A20)to count visible text cells only when a filter is applied. - Combine
IFERRORwith your formula to handle unexpected errors:=IFERROR(SUMPRODUCT(--ISTEXT(A1:A20)),0). - Highlight counted cells with conditional formatting: apply a rule that formats cells where
ISTEXT(A1)is true. - When working with large datasets, convert the range to an Excel Table; formulas automatically adjust as rows are added.
- Use the
Find & Replacedialog to locate all cells containing a specific word, then manually count if needed. - For case‑sensitive counting, combine
EXACTwithSUMPRODUCT:=SUMPRODUCT(--EXACT(A1:A20,"desiredText")).
Troubleshooting
- Formula returns
0or an unexpected number. Check that the range includes the intended cells and that the formula syntax is correct. Ensure the range is not inadvertently locked or protected. - Formula shows
#VALUE!. This often occurs if the range contains errors. UseIFERRORorAGGREGATEto bypass them. - Formula counts numbers as text. Use
SUMPRODUCT(--ISTEXT(range))to restrict counting to true text entries. - Hidden rows affect the count. Replace
COUNTIFwithSUBTOTAL(103, range)to count only visible cells. - If the formula still returns zero, double‑check that the cells are not formatted as Text but actually contain text. You can re‑enter the data or use the Text‑to‑Columns tool to convert them.
Frequently Asked Questions
Can I count cells that contain only spaces?
No, because those cells are considered blank. Use TRIM or LEN(TRIM(cell))>0 to exclude them.
Does COUNTIF ignore hidden rows?
No, COUNTIF counts all cells in the range, regardless of visibility. Use SUBTOTAL(103, range) for visible‑only counts.
How do I count text that includes numbers, like “ABC123”?
Both COUNTIF(range,"*") and SUMPRODUCT(--ISTEXT(range)) will count such cells because they contain text characters.
Can I use a VBA macro to count text cells?
Yes, a simple loop using If IsText(cell) Then count = count + 1 will do the job, but the built‑in formulas are usually faster.
What if I need a case‑sensitive count?
Use SUMPRODUCT(--EXACT(range,"text")) to count only cells that match the exact case.