How to Count Cells with Specific Text in Excel

📅 Feb 24, 2026 📝 Sarah Miller

Manually auditing spreadsheet rows to track specific keywords is tedious and highly prone to human error. This challenge is especially common when organizing complex databases, where sorting through standard funding sources-such as state grants, federal allocations, or private donations-requires absolute precision. Utilizing the COUNTIF formula grants analysts immediate, automated visibility into their data metrics. However, one key stipulation is managing text variations; you must decide whether to target exact matches or use wildcard characters for partial text. For example, applying =COUNTIF(A2:A100, "*Federal*") quickly isolates specific funding streams. Below, we outline the exact syntax and configurations needed to implement this solution.

How to Count Cells with Specific Text in Excel

In data analysis, categorization, and general spreadsheet management, counting how often a specific text, word, or substring appears is one of the most common tasks. Whether you are analyzing customer feedback, tracking inventory, or auditing project status reports, Excel provides several powerful ways to count cells containing specific text.

This comprehensive guide will walk you through the essential Excel formulas for counting cells with specific text, ranging from basic exact matches to advanced wildcard searches, case-sensitive counts, and criteria-based multiple-text evaluation.


1. Basic Count: Exact Match Using COUNTIF

If you need to count cells that contain exactly a specific word or phrase-with no extra spaces or characters-the COUNTIF function is your go-to tool.

The Formula Syntax

=COUNTIF(range, criteria)
  • range: The group of cells you want to search through (e.g., A2:A100).
  • criteria: The specific text you are looking for. It must be enclosed in double quotation marks (e.g., "Completed").

Example: Counting Exact Statuses

Imagine you have a sales tracker in column B, and you want to count how many orders are "Delivered".

Row A (Product) B (Status)
2 Laptop Delivered
3 Smartphone Pending
4 Headphones Delivered
5 Keyboard delivered

To count the number of exact "Delivered" statuses, use this formula:

=COUNTIF(B2:B5, "Delivered")

Result: 3. Note that COUNTIF is case-insensitive by default, so it counts "Delivered", "delivered", and "DELIVERED" equally.

2. Partial Match: Using Wildcard Characters (* and ?)

Often, the text you are looking for is buried inside other text. For example, you might want to count all cells containing "Apple", which could include "Apple iPhone", "Red Apples", or "Green Apple Juice". To achieve this, Excel uses wildcard characters:

  • * (Asterisk) represents any sequence of zero or more characters.
  • ? (Question Mark) represents any single character.

A. Cells Containing Specific Text Anywhere

To count cells that contain a specific text string anywhere within the cell, wrap your search term in asterisks:

=COUNTIF(range, "*text*")

Example: To count any cell in A2:A10 that contains the word "Apple":

=COUNTIF(A2:A10, "*Apple*")

B. Cells Starting with Specific Text

To count cells that begin with a specific word or set of characters, place the asterisk at the end of the criteria:

=COUNTIF(range, "text*")

Example: Count cells starting with "North" (e.g., "North America", "North Region"):

=COUNTIF(A2:A10, "North*")

C. Cells Ending with Specific Text

To count cells that end with a specific suffix or word, place the asterisk at the beginning of the criteria:

=COUNTIF(range, "*text")

Example: Count all email addresses ending with ".com":

=COUNTIF(A2:A10, "*.com")

D. Using Cell References with Wildcards

Instead of hardcoding text inside the formula, you can reference another cell (e.g., cell D1) that contains your search term. Use the concatenation operator (&) to join the wildcards with the cell reference:

=COUNTIF(A2:A10, "*" & D1 & "*")

3. Advanced: Case-Sensitive Text Counting

Because the standard COUNTIF and COUNTIFS functions ignore case differences, counting cells while differentiating between uppercase and lowercase requires a different approach. We can combine the SUMPRODUCT function with the case-sensitive EXACT function.

The Formula Syntax

=SUMPRODUCT(--(EXACT(range, "Text")))

How It Works:

  • EXACT(range, "Text") compares every cell in the range with the specified text. It returns an array of TRUE (if it is a perfect, case-sensitive match) and FALSE (if it is not).
  • The double negative (--), also known as the double unary operator, converts the boolean TRUE and FALSE values into 1s and 0s, respectively.
  • SUMPRODUCT sums up the resulting array of 1s and 0s to give you the exact case-sensitive count.

Example:

If you have values "ID-100", "id-100", and "ID-100" in cells A2:A4, and you only want to count "ID-100":

=SUMPRODUCT(--(EXACT(A2:A4, "ID-100")))

Result: 2 (ignoring the lowercase "id-100").

4. Counting with Multiple Text Criteria (AND / OR)

Real-world data manipulation often requires counting cells based on more than one condition.

A. AND Logic (Using COUNTIFS)

To count cells that meet multiple text criteria across different columns, use the COUNTIFS function (with an "S" at the end).

=COUNTIFS(range1, criteria1, range2, criteria2, ...)

Example: Count rows where the Region (Col A) is "West" AND the Product (Col B) contains "Pro":

=COUNTIFS(A2:A10, "West", B2:B10, "*Pro*")

B. OR Logic (Using SUM and COUNTIF Array)

To count cells that match one of several different text criteria within the same range (e.g., cells that contain either "Completed" or "In Progress"), use an array constant inside a SUM and COUNTIF formula:

=SUM(COUNTIF(range, {"text1", "text2", "text3"}))

Example: Count how many projects are either "High" or "Medium" priority:

=SUM(COUNTIF(B2:B10, {"High", "Medium"}))

5. Counting Cells Containing Any Text (Excluding Numbers & Blanks)

Sometimes you don't need to look for a specific word, but instead want to count any cell that contains text values, while ignoring empty cells, numbers, errors, and dates.

The Formula:

=COUNTIF(range, "*")

The asterisk wildcard matches any text string of any length. Because numbers are not interpreted as text strings, they are ignored by this formula.

What if your text contains empty strings returned by formulas?

If your range has formulas that return empty strings (""), the formula above might count them. To count only cells containing visible, non-empty text, use:

=COUNTIF(range, "?*")

This tells Excel to count cells containing at least one character (? represents one character, and * represents any subsequent characters).

6. Best Practices & Troubleshooting Common Errors

A. Handling Hidden Spaces

If your COUNTIF formulas are returning lower numbers than expected, it is often due to trailing or leading spaces in your data (e.g., "Delivered " instead of "Delivered").

  • The Fix: Use the TRIM function to clean your dataset before counting, or use wildcards to bypass the extra spaces: =COUNTIF(A2:A10, "*Delivered*").

B. Counting Cells with Special Characters

If you need to count cells containing actual wildcard characters like question marks (?) or asterisks (*), Excel will treat them as wildcards by default.

  • The Fix: Use a tilde (~) before the wildcard character in your criteria to tell Excel to treat it as a literal character. For example, to count cells that end with a question mark: =COUNTIF(A2:A10, "*~?").

C. Performance in Large Worksheets

While formulas like SUMPRODUCT with EXACT are highly versatile, they calculate as array formulas. On thousands of rows of data, excessive use of array functions can slow down Excel's performance. For massive datasets, consider utilizing Excel's Power Query or Pivot Tables to group and count text strings efficiently.


Summary Cheat Sheet

Objective Formula Pattern
Exact text match =COUNTIF(A2:A10, "Text")
Contains specific text (anywhere) =COUNTIF(A2:A10, "*Text*")
Starts with specific text =COUNTIF(A2:A10, "Text*")
Ends with specific text =COUNTIF(A2:A10, "*Text")
Case-sensitive exact match =SUMPRODUCT(--(EXACT(A2:A10, "Text")))
Multiple criteria (OR logic) =SUM(COUNTIF(A2:A10, {"Text1","Text2"}))
Count cells with any text =COUNTIF(A2:A10, "*")

Disclaimer:
The documents and templates provided on this page are for informational and illustrative purposes only. They do not constitute professional, legal, or financial advice, and should not be relied upon as such. Because individual circumstances and regulatory requirements vary, these materials may not be suitable for your specific needs. We recommend consulting with a qualified professional before adapting or using any of these examples for official or commercial purposes.