Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

CountIf Words in Excel: How to Count Specific Text

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To count specific words in Excel, use the =COUNTIF(range, "word") formula for exact matches, or =COUNTIF(range, "*word*") with asterisks as wildcards to count cells that contain the word anywhere in the text. This allows you to quickly quantify occurrences of a specific term across a dataset without manual counting.

What You'll Need

  • Microsoft Excel (any version from 2007 onwards) or Google Sheets.
  • A dataset containing the text or words you wish to analyze.
  • A basic understanding of how to select a range of cells.

Step-by-Step

  1. Prepare Your Data: Ensure your data is organized in a column or row. For example, if you have a list of customer feedback in column A (from A2 to A100), this will be your "range."
  2. Select the Output Cell: Click on the empty cell where you want the final count to appear. This is usually a cell outside your data range to avoid circular reference errors.
  3. Enter the Formula for Exact Matches: If you want to count cells that contain only the specific word and nothing else, type the following: =COUNTIF(A2:A100, "Apple"). Replace "A2:A100" with your actual range and "Apple" with the word you are looking for. Press Enter.
  4. Enter the Formula for Partial Matches (Wildcards): In most cases, a cell contains a sentence or multiple words. To count every cell that contains the word "Apple" regardless of what other text is in the cell, use wildcards. Type: =COUNTIF(A2:A100, "*Apple*"). The asterisks act as placeholders for any number of characters before or after the word.
  5. Using a Cell Reference for the Criteria: Instead of typing the word directly into the formula, you can type the word in a separate cell (e.g., cell C1) and reference it. This makes it easier to change the word you are counting without editing the formula. Use the formula: =COUNTIF(A2:A100, "*" & C1 & "*"). The ampersand (&) joins the wildcards to the value in cell C1.
  6. Counting Case-Insensitive Results: Note that the standard COUNTIF function is not case-sensitive. Searching for "apple" will also count "Apple" and "APPLE". If you need a case-sensitive count, you will need a more complex formula involving the SUMPRODUCT and EXACT functions.
  7. Applying the Formula to Multiple Words: If you have a list of five different words you want to count, create a small table with the words in one column and the COUNTIF formula in the next, using the cell reference method described in step 5. You can then drag the fill handle down to apply the formula to all words in your list.

Common Mistakes

One of the most frequent errors is forgetting the quotation marks around the text criteria. In Excel formulas, any text string must be enclosed in double quotes; otherwise, Excel interprets the word as a named range or a function, resulting in a #NAME? error. Another common mistake is forgetting the wildcards when searching for a word within a sentence. If you use =COUNTIF(A2:A100, "Apple") on a cell that says "I love Apple products," Excel will not count it because the cell does not exactly match "Apple".

Users also frequently struggle with hidden spaces. A cell that looks like it contains "Apple" might actually contain "Apple " (with a trailing space). An exact match COUNTIF will ignore this cell. To fix this, you can use the TRIM function to clean your data before counting, or rely on the wildcard method which naturally ignores surrounding spaces.

Another mistake is selecting the entire column (e.g., A:A) when the dataset is massive. While this is convenient, it can slow down workbook performance in very large files. It is generally better to define a specific range, such as A2:A5000, to keep the spreadsheet responsive.

Tips

To make your counting process more dynamic, use a Data Validation drop-down list. Create a list of the words you want to track, set up a drop-down menu in cell C1, and link your COUNTIF formula to that cell. This allows you to toggle between different words and see the counts update instantly without typing.

If you need to count how many times a word appears in total across all cells (meaning if a word appears twice in one cell, it counts as two), COUNTIF will not work because it only counts the number of cells that meet the criteria. To count total occurrences, use this logic: subtract the length of the cell text without the word from the total length of the cell text, then divide by the length of the word itself. The formula looks like this: =SUMPRODUCT((LEN(A2:A100)-LEN(SUBSTITUTE(A2:A100,"Apple","")))/LEN("Apple")).

For those working with very large datasets, consider converting your data range into an official Excel Table (Ctrl + T). When you use a Table, you can use structured references (like =COUNTIF(Table1[Feedback], "*Apple*")). The benefit here is that as you add new rows to the bottom of the table, the COUNTIF range expands automatically, so you never have to update the formula range manually.

Troubleshooting

If your formula is returning 0 when you know the word exists, first check for trailing or leading spaces in your data. You can test this by clicking into a cell and seeing if the cursor blinks a few spaces away from the last letter. If spaces are the issue, use the =TRIM() function in a helper column to remove them.

If you see a #VALUE! error, check that your range is valid. Ensure you haven't accidentally included a range that spans across different sheets in a way the formula cannot handle, or that you aren't referencing a deleted range. If you see a #NAME? error, double-check that you have enclosed your text criteria in double quotes (e.g., "Apple" instead of Apple).

If the count seems too high, check if your search word is a subset of another word. For example, searching for "Art" using wildcards will also count "Heart," "Artist," and "Partial." To avoid this, you can add spaces inside the wildcards: " * Art * ", though this may miss the word if it is at the very beginning or end of the cell. A more robust way to handle this is to use a helper column to split the text into individual words using "Text to Columns" and then running the COUNTIF on those individual cells.

Frequently Asked Questions

Can I count multiple different words at once?

Yes, you can add multiple COUNTIF functions together. For example, =COUNTIF(A2:A100, "*Apple*") + COUNTIF(A2:A100, "*Orange*") will give you the combined total of cells containing either word.

Does COUNTIF distinguish between uppercase and lowercase?

No, COUNTIF is case-insensitive. It treats "APPLE," "apple," and "Apple" as the same word. For case-sensitive counting, you must use a combination of SUMPRODUCT and EXACT.

How do I count cells that do NOT contain a certain word?

You can use the "not equal to" operator. The formula =COUNTIF(A2:A100, "<>*Apple*") will count all cells that do not contain the word "Apple".

Can I use COUNTIF to count words across multiple sheets?

COUNTIF does not natively support 3D ranges (ranges across multiple sheets). To do this, you must write a separate COUNTIF for each sheet and sum them together, or use a more advanced tool like Power Query to combine the data first.

What is the difference between COUNTIF and COUNTIFS?

COUNTIF is used for a single criterion. COUNTIFS allows you to apply multiple criteria to the same or different ranges. For example, you could count cells that contain "Apple" AND were submitted in the month of "January".