Smart Systems for Home

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

Counting Text in Excel: How to Use COUNTIF and Formulas

· 5 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 text in Excel, the most efficient method is using the COUNTIF function for specific words or the COUNTA function for any cell containing text. For example, to count how many times "Completed" appears in a range, use =COUNTIF(range, "Completed"); to count all non-empty cells, use =COUNTA(range).

Counting text allows you to analyze datasets quickly without manual tallying. Whether you are tracking project statuses, counting customer names, or searching for specific keywords within a large sheet, Excel provides several ways to automate this process depending on whether you need an exact match, a partial match, or a total count of all text entries.

What You'll Need

  • Microsoft Excel (any version)
  • A dataset containing the text strings you wish to count
  • Basic familiarity with selecting cell ranges

Step-by-Step

  1. Identify your range: Determine which cells contain the data you want to analyze. For example, if your data is in column A from row 2 to 100, your range is A2:A100.
  2. Count a specific word (Exact Match):
    • Click on an empty cell where you want the result to appear.
    • Type =COUNTIF(.
    • Highlight your range (e.g., A2:A100) or type it manually.
    • Type a comma, then the word you are looking for in double quotation marks. For example: =COUNTIF(A2:A100, "Pending").
    • Press Enter.
  3. Count cells containing any text (Non-Empty):
    • Click on an empty cell.
    • Type =COUNTA(.
    • Highlight the range you want to count.
    • Close the parenthesis and press Enter. For example: =COUNTA(A2:A100). This counts every cell that is not empty, regardless of whether it contains text, numbers, or errors.
  4. Count partial text matches (Wildcards):
    • If you want to count cells that contain a word but aren't an exact match (e.g., counting "Apple" in cells that say "Red Apple" and "Green Apple"), use the asterisk (*) wildcard.
    • Type =COUNTIF(range, "*Apple*").
    • The asterisks tell Excel to count any cell where "Apple" appears, regardless of what text comes before or after it.
  5. Count cells containing text while ignoring numbers:
    • To count only cells that contain text strings and ignore cells that contain only numbers, use the wildcard inside the COUNTIF function.
    • Type =COUNTIF(range, "*").
    • This tells Excel to count any cell that contains one or more characters of text.
  6. Count based on a cell reference:
    • Instead of typing the word into the formula, type the word into a separate cell (e.g., C1).
    • Use the formula =COUNTIF(A2:A100, C1).
    • This allows you to change the word in cell C1 to instantly update the count without editing the formula.

Common Mistakes

  • Forgetting Quotation Marks: When typing text directly into a formula (like "Pending"), you must use double quotes. If you omit them, Excel will look for a named range or return a #NAME? error.
  • Confusing COUNT and COUNTA: The =COUNT() function only counts numbers. If you use it on a column of text, it will return 0. Always use =COUNTA() for text.
  • Hidden Spaces: A cell that looks like it says "Apple" but actually says "Apple " (with a trailing space) will not be counted by an exact match =COUNTIF(range, "Apple").
  • Case Sensitivity: By default, COUNTIF is not case-sensitive. It will treat "APPLE", "apple", and "Apple" as the same word.

Tips

  • Use Tables: Convert your data range into an official Excel Table (Ctrl+T). This makes your formulas dynamic, meaning if you add new rows to the bottom, the count formula updates automatically.
  • Combine with SUMPRODUCT: For very advanced counting (such as counting how many times a specific word appears within a single cell), you can use a combination of LEN and SUBSTITUTE functions inside a SUMPRODUCT formula.
  • Use Filter: If you only need a quick count without a formula, click the Filter icon in the Data tab, filter for the word you want, and look at the bottom-left status bar of the Excel window; it will show "X of Y records found."

Troubleshooting

If your formula is not returning the expected result, try these steps in order:

  1. Check for trailing spaces: Use the =TRIM() function to remove extra spaces from your data, or use the wildcard method =COUNTIF(range, "*Word*") to see if the count increases.
  2. Verify the range: Ensure your range covers all the data. If you added new rows, your formula might still be looking at the old range (e.g., A2:A100 when your data now goes to A150).
  3. Check for formula errors: If you see #VALUE! or #NAME?, check that your parentheses are closed and that your text criteria are enclosed in double quotes.
  4. Refresh Calculations: If the number isn't updating, go to the Formulas tab > Calculation Options and ensure "Automatic" is selected.

Frequently Asked Questions

Can I count text based on multiple criteria?

Yes. Use the =COUNTIFS() function (with an 'S' at the end). This allows you to add multiple ranges and criteria, such as counting cells that say "Completed" AND "High Priority".

How do I count only empty cells?

Use the =COUNTBLANK(range) function. This specifically counts cells that are completely empty or contain an empty string returned by a formula.

Why is my COUNTIF returning 0 when I can clearly see the text?

This is usually caused by non-printing characters or leading/trailing spaces. Try using the wildcard "*text*" to see if the count changes; if it does, your data needs cleaning.

Is there a way to count unique text values?

In newer versions of Excel, you can use =COUNT(UNIQUE(range)) or =COUNTA(UNIQUE(range)). This creates a list of unique items and then counts how many there are.

Can I count text that starts with a specific letter?

Yes. Use the wildcard at the end of the letter. For example, =COUNTIF(range, "A*") will count all cells that start with the letter A.