Count Cells Containing Text in Excel and Google Sheets
In this article
To count how many cells contain text, use the formula =COUNTIF(range, "*"). This specific formula uses a wildcard character (the asterisk) to identify any cell that contains one or more text characters, while ignoring cells that contain only numbers, dates, or are completely empty. This is the most efficient way to isolate string data from numeric data in a mixed dataset.
Counting text-based cells is a fundamental data cleaning and analysis task. Whether you are managing a client list, tracking project statuses, or auditing a survey, you often need to know how many entries are qualitative (text) versus quantitative (numbers). While the standard COUNT function only counts numbers, and COUNTA counts everything that isn't empty, the COUNTIF method allows you to be surgical about what you are measuring. This guide covers how to implement this across the most common spreadsheet applications, including Microsoft Excel and Google Sheets.
What You'll Need
- A spreadsheet application (Microsoft Excel, Google Sheets, or LibreOffice Calc).
- A dataset containing a mix of text, numbers, and empty cells.
- Basic familiarity with selecting cell ranges (e.g., A1:A50).
Step-by-Step
- Identify Your Target Range: Determine which column or block of cells you want to analyze. For example, if your names are in column A from row 2 to row 100, your range is
A2:A100. - Select the Output Cell: Click on the empty cell where you want the final count to appear. This is usually located at the bottom of your data column or in a separate summary table.
- Enter the Formula: Type the following exactly as written:
=COUNTIF(. - Define the Range: While the cursor is still inside the parentheses, highlight the cells you identified in step one with your mouse, or type the range manually (e.g.,
A2:A100). Follow this with a comma. - Apply the Text Criterion: Type
"*"(a double quote, an asterisk, and another double quote). The asterisk is a wildcard that represents any sequence of characters. Because numbers are not considered characters in this specific context, the formula will ignore them. - Close and Execute: Type the closing parenthesis
)and press Enter. The cell will now display the total number of cells containing text. - Verify the Result: To ensure accuracy, manually count a small sample of your text cells to see if the formula result matches your manual count.
Common Mistakes
One of the most frequent errors is using the COUNTA function instead of COUNTIF. While COUNTA stands for "count all," it counts every cell that is not empty. This means if your column contains a mix of names (text) and ID numbers (numbers), COUNTA will give you the total of both. If you only want the names, COUNTA will provide an inflated and incorrect number.
Another common mistake is forgetting the double quotes around the asterisk. In spreadsheet logic, text criteria must be wrapped in quotation marks. If you enter =COUNTIF(A1:A10, *) without quotes, the software will return a formula error (usually a #NAME? or #VALUE! error) because it thinks the asterisk is a named range or a mathematical operator rather than a search criterion.
Users also frequently mistake "blank" cells for "empty" cells. A cell that looks empty but contains a space character (hit by the spacebar) is technically considered text. The "*" formula will count these "invisible" text cells, which can lead to a count that is higher than what you see visually on the screen.
Tips
If you need to count cells that contain either text or numbers (essentially counting everything that isn't blank), use =COUNTA(range). This is the fastest way to find the total number of entries in a list regardless of data type.
For those working with very large datasets, you can use the "Filter" feature to double-check your work. Apply a filter to your header row, click the filter dropdown for the column, and uncheck everything except the text values. The status bar at the bottom of the window will often show the count of filtered records, which should match your COUNTIF result.
If you want to count cells that contain a specific piece of text, you can replace the asterisk with a specific word in quotes, such as =COUNTIF(A1:A100, "Completed"). To count cells that contain a specific word as part of a longer sentence, wrap the word in asterisks: =COUNTIF(A1:A100, "*urgent*"). This will count any cell where the word "urgent" appears anywhere in the text.
Troubleshooting
If your formula is returning 0 when you know there is text in the range, first check if your "text" is actually formatted as numbers. Sometimes data imported from other software looks like text but is stored as a numeric value. You can check this by selecting a cell and looking at the formatting dropdown in the top toolbar; if it says "Number" or "Currency," the "*" wildcard will ignore it.
If the count is higher than expected, you likely have "ghost characters" or trailing spaces. To fix this, you can use the TRIM function in a helper column to remove extra spaces, or use the "Find and Replace" tool (Ctrl+H) to find a single space and replace it with nothing, though be careful not to remove spaces between words.
If you receive a #VALUE! error, check your syntax. Ensure you have used a comma to separate the range from the criteria. In some European regions, spreadsheet software uses a semicolon (;) instead of a comma (,) as the formula delimiter. If the comma fails, try =COUNTIF(A1:A100; "*").
If the formula does not update when you add new text to the range, check your calculation settings. In Excel, go to the Formulas tab > Calculation Options and ensure "Automatic" is selected. If it is set to "Manual," the count will not change until you press F9.
Frequently Asked Questions
Does this count cells with formulas that result in text?
Yes. If a cell contains a formula like =CONCATENATE("User ", A1), the resulting value is text, and the COUNTIF(range, "*") formula will count it.
Will this count cells that only contain a single space?
Yes. A space is considered a text character. If a cell appears empty but contains one or more spaces, it will be included in the count.
Can I count cells that contain ONLY numbers using a similar method?
Yes, but you don't need a wildcard. Simply use the =COUNT(range) function, which is designed specifically to count only numeric values and ignore text.
Does this work for dates?
No. In most spreadsheet programs, dates are stored as serial numbers. Therefore, COUNTIF(range, "*") will ignore dates. To count dates, use the standard COUNT function.
How do I count cells that are NOT text?
You can use the COUNTBLANK function to find empty cells, or subtract your text count from the total number of cells in the range using the ROWS function: =ROWS(range) - COUNTIF(range, "*").
Does this work in LibreOffice Calc?
Yes, the COUNTIF function and the asterisk wildcard are standard across almost all spreadsheet software, including LibreOffice and Apple Numbers.