The COUNTIF function counts cells that meet a specific condition in Excel. To count text, you must wrap the text you are looking for in double quotation marks, like this: =COUNTIF(A1:A10, "Apple"). This tells Excel to look for the exact word "Apple" and return the number of times it appears in the range.
What You'll Need
- A computer or device with Microsoft Excel installed (Desktop, Web, or Mobile).
- A spreadsheet containing data with text entries.
- Basic knowledge of typing formulas into a cell.
Step-by-Step
- Locate the cell where you want the result. Click on the empty cell where you want to see the total count. This is often the cell immediately below your data or in a separate "Summary" area.
- Start the formula. Type an equals sign (
=) to begin entering a formula. Then, typeCOUNTIF. Excel will typically suggest the function name; press Enter or Tab to accept it. - Specify the range. After the function name, add an opening parenthesis
(. Then, click and drag your mouse to select the cells you want to search through. For example, if your data is in columns A through C, you might selectA1:A100. Close the parenthesis with a closing bracket). - Enter the criteria (the text). Type a comma
,to separate the range from the criteria. Now, type the text you want to count inside double quotation marks. Ensure the text matches the casing if you are doing a case-sensitive check, though COUNTIF is generally case-insensitive. - Close and finish. Type the final closing parenthesis
)and press Enter. The cell will now display the number of times your specific text appears in the range.
Common Mistakes
One of the most frequent errors when using COUNTIF for text is forgetting the quotation marks. If you type =COUNTIF(A1:A10, Apple) without quotes, Excel will treat "Apple" as a cell reference (cell A1, A, P, P, L, E) and return a #VALUE! error or a count of zero.
Another common mistake is trying to count cells that contain any text. To do this, you must use an asterisk wildcard. The formula =COUNTIF(A1:A10, "*") counts every cell that contains at least one character (letters, numbers, symbols). Note that this will not count truly empty cells.
Users also often struggle with partial matches. If you want to count cells containing the word "Apple" regardless of what comes before or after it, use the asterisk wildcards on both sides: =COUNTIF(A1:A10, "*Apple*").
Tips
Use wildcards for flexibility. The asterisk * represents any number of characters. The question mark ? represents a single character. For example, "*est*" will count "Test", "The Best", and "Rest". "A?e" will count "Ace", "Ade", or "Abe" but not "Apple".
Check for hidden spaces. Sometimes a cell looks empty but contains a space character. The formula =COUNTIF(A1:A10, " ") will count these invisible characters. To clean this data, use the TRIM() function on your data range before counting.
Combine with other functions. You can nest COUNTIF inside an IF function to create decision-making formulas. For instance, =IF(COUNTIF(A1:A10, "Apple")>0, "Found", "Not Found") will return a text message instead of a number.
Troubleshooting
If your formula returns a result of zero (0) even though you know the text is there, check the spelling. Excel treats "Apple" and "apple" as different strings in a case-sensitive context, though the standard COUNTIF function is generally case-insensitive. However, if you are using a specific variation or locale that enforces case sensitivity, a mismatch in capitalization will cause the count to fail.
Also, ensure your criteria text does not include spaces. If you type " Apple " with spaces inside the quotes, Excel will only count cells that start with a space, followed by the word Apple, followed by a space.
Frequently Asked Questions
How do I count cells that contain specific text but not others?
Use the NOT function combined with COUNTIF. The formula =COUNTIF(A1:A10, "<>*Apple*") counts every cell in the range that does not contain the word "Apple".
Can I count text in multiple columns at once?
Yes. You can select a non-contiguous range by holding the Ctrl key (Windows) or Command key (Mac) while clicking different areas. For example: =COUNTIF((A1:A10, B1:B10), "Apple"). Alternatively, use the UNION operator by adding a comma between ranges inside the parentheses.
Why does COUNTIF return a #VALUE! error?
This error usually happens when the criteria argument is not text. If you type a number without quotes, Excel tries to do math. It can also happen if the range contains data types that Excel cannot interpret as text or numbers, such as complex error values.
How do I count blank cells?
Use an empty string double quotes. The formula =COUNTIF(A1:A10, "") counts every empty cell in the range. This is distinct from the wildcard "*", which counts every cell that has at least one character.