Use COUNTIF for case-insensitive matches. For case-sensitive exact matches, use =SUMPRODUCT(--EXACT(range,criteria)). For case-sensitive contains matches, use =SUMPRODUCT(--ISNUMBER(FIND(criteria,range))). If you choose the wrong match type, Excel can return a count that looks fine while missing case differences. This guide shows the shortest formula for each job, then the common failure points to check.

COUNTIF case-sensitivity basics

An Excel sheet lists revenue and person names beside a COUNTIFS result
The single criteria counter performs case-insensitive text comparison, treating Apple and apple the same.

COUNTIF follows COUNTIF(range, criteria) and counts one criterion at a time. For text, it does not distinguish upper and lower case, so Apple and apple are treated the same. It supports wildcards, but that does not make it case-sensitive. (Microsoft Support)

That is why COUNTIF fits simple totals and status labels, but not text where letter case matters. It can also return errors in closed-workbook references, and it can miscount when hidden spaces or text-formatted numbers are in the range.

Why COUNTIF ignores upper and lower case?

COUNTIF is built as a single-criteria counter, and its text comparison is case-insensitive. Excel Support also notes that COUNTIF can count values greater than a number using logical criteria, so the function is set up for broad matching rules rather than exact text comparison.

For literal text, the wildcard rules are simple. An asterisk matches any sequence of characters, a question mark matches one character, and a tilde escapes a literal wildcard character. None of those options makes the function case-sensitive.

When wildcards help and when they do not

Wildcards help when the text is only partly known. For example, =COUNTIF(A2:A10,"App*") counts labels that begin with App, and =COUNTIF(A2:A10,"??-1") counts two-character prefixes followed by -1. The count still ignores case.

Wildcards do not solve exact case matching. If you need AB-12 but not ab-12, COUNTIF alone cannot separate them. That is the point where EXACT or FIND is the right tool.

Exact match or substring?

Choose the formula by deciding what you know about the text. If you know the full label and need an exact match, use EXACT. If you only know part of the label and need to count cells that contain that text anywhere, use FIND with ISNUMBER. Make that decision before you write the formula.

Say your list contains Red, RED, and Redwood. If you need only the exact label Red, use an exact-match formula. If you need every cell that contains Red anywhere in the text, use a contains-match formula.

Suppose a summary table has labels like Open, Closed, and On hold. A simple COUNTIF works if case does not matter. If the source data mixes open and Open and you need separate counts, move to EXACT or FIND.

COUNTIF decision table

This table gives the shortest formula pattern for the goal you actually have. Start here, then check the failure mode if the count still looks wrong.

Goal Best formula pattern Common failure mode
Exact match, case-sensitive =SUMPRODUCT(--EXACT(range,criteria)) Hidden spaces or nonprinting characters make equal-looking text fail
Substring match, case-sensitive =SUMPRODUCT(--ISNUMBER(FIND(criteria,range))) Text stored as numbers or extra spaces change what FIND sees
Case-sensitive duplicate counting =SUMPRODUCT(--EXACT(range,cell)) Blank cells and formatted blanks can look like duplicates
Summary-table counting =SUMPRODUCT(--EXACT(data,label)) or =SUMPRODUCT(--ISNUMBER(FIND(label,data))) Copied formulas break if the label reference is fixed the wrong way

If this returns the wrong count: check for leading or trailing spaces, look for nonprinting characters, confirm that numbers are not stored as text, and test whether the source range points to a closed workbook.

How do you count exact text matches?

For a case-sensitive exact match, use EXACT inside SUMPRODUCT: =SUMPRODUCT(--EXACT(range,criteria)). EXACT returns TRUE or FALSE for each cell, and SUMPRODUCT adds the results without needing Ctrl+Shift+Enter in modern Excel. This is a common reliable pattern for exact text counting.

EXACT is the function to use for case-sensitive text comparison, and it is the right choice when the full cell text must match exactly. The double minus converts TRUE/FALSE into 1/0 so SUMPRODUCT can total them.

  1. Enter the exact-match formula. Put your target text in a cell, then compare the range to that cell. For example, =SUMPRODUCT(--EXACT(A2:A20,C2)) counts exact, case-sensitive matches to the text in C2.
  2. Check the source text. If the count is too low, inspect the source cells for leading spaces, trailing spaces, or nonprinting characters. Two cells can look identical and still fail EXACT if one has hidden characters.
  3. Use array behavior correctly. In older Excel, SUMPRODUCT handles array results natively, so it usually avoids Ctrl+Shift+Enter. That makes it a safer choice than a plain array formula for many workbooks.

A common first-timer mistake is expecting =COUNTIF(A2:A20,C2) to separate North from north. It will not. If case matters, switch to EXACT before you spend time checking the wrong part of the workbook.

How do I count case-sensitive substrings in Excel?

For a case-sensitive contains match, use =SUMPRODUCT(--ISNUMBER(FIND(criteria,range))). FIND is always case-sensitive, returns a position number when it finds the text, and returns #VALUE! when it does not. ISNUMBER turns those results into TRUE or FALSE for counting.

Exceljet’s substring pattern uses FIND with ISNUMBER because it handles partial text safely. SUMPRODUCT then totals the TRUE values without requiring Ctrl+Shift+Enter in modern Excel, and it also works with array-style formulas in older Excel.

  1. Place the substring once. Put the text you want to find in a single cell, then point the formula at that cell. For example, =SUMPRODUCT(--ISNUMBER(FIND(C2,A2:A20))) counts cells in A2:A20 that contain the text in C2 with matching case.
  2. Read the output type. FIND returns a number when it finds the text, so ISNUMBER converts that number to TRUE. If FIND cannot find the substring, it returns an error, and ISNUMBER converts that to FALSE for the count.
  3. Keep the match rule consistent. If you only need an exact label, do not use FIND. It will count any cell that contains the text anywhere, which is useful for partial matches but wrong for exact-match labels.

Picture a SKU list where AB must count, but ab must not. =SUMPRODUCT(--ISNUMBER(FIND("AB",A2:A20))) counts only the uppercase hits. A lower-case version in the same column will be ignored because FIND checks case.

Why is COUNTIF returning the wrong count?

An Excel sheet lists items beside a COUNTIF formula for matching names
COUNTIF uses stored text, so hidden spaces can change the count.

COUNTIF can look correct and still miss the mark because the data is not clean. Leading or trailing spaces, nonprinting characters, numbers stored as text, and closed-workbook references can all change the result. Syntax may be right while the count is still wrong.

COUNTIF can also return an incorrect value for strings longer than 255 characters, and it can return #VALUE! when the reference points to another worksheet in a closed workbook. Those failures are separate from case sensitivity, but they often appear in the same troubleshooting session.

Spaces and nonprinting characters

Hidden spaces are a common cause of false mismatches. Red and Red are not equal, even though they may look the same in the grid. EXACT and FIND both depend on the text as stored, not the text as displayed.

If the data comes from another system, trim the inputs or normalize them before counting. A formula can be correct and still fail when the source contains invisible characters that change the comparison.

Text stored as numbers

Numbers stored as text can confuse a formula that expects a number or a text label in a specific format. 0012 and 12 are different text values, and a count can change if one column stores the value as text while another stores it as a number.

If a count looks off, check the cell format and the visible text together. This matters most in IDs, codes, and parts lists where leading zeros are meaningful.

Closed workbook references

COUNTIF can fail when the referenced range is in a workbook that is closed. In that case, Excel can return #VALUE! instead of a count. Open the source workbook, recalculate, and test again before rewriting the formula.

If the workbook must stay closed, use a layout that keeps the needed data in the open file. That is often easier than trying to patch a formula that was built for a live workbook reference.

Multiple labels in a summary

For a summary table, build one formula pattern and copy it across labels. The label cell should be the criteria reference, not hard-coded text. That keeps the count reusable and makes it easier to audit when the source data changes.

For exact-match summaries, use =SUMPRODUCT(--EXACT($A$2:$A$20,B2)), where B2 holds the label. For contains-match summaries, use =SUMPRODUCT(--ISNUMBER(FIND(B2,$A$2:$A$20))). The first pattern counts exact labels; the second counts any cell that contains the label.

  1. Store labels in cells. Put each summary label in its own cell, then point the formula to that cell. This makes the formula easier to copy and keeps the criterion visible on the sheet.
  2. Lock the data range. Use absolute references for the source range, such as $A$2:$A$20, so the data does not shift when you copy the formula across the summary table. Leave the label reference relative if each row should count a different label.
  3. Choose the right match type. Use EXACT for labels that must match the whole cell, and FIND when the summary should count any cell that contains the label. Mixing those patterns is a frequent source of wrong totals.

Keep reading

Frequently asked questions

How do I make COUNTIF case sensitive in Excel?

You cannot make COUNTIF case-sensitive on its own. COUNTIF is not case-sensitive for text, so the usual fix is to switch to =SUMPRODUCT(--EXACT(range,criteria)) for exact matches or =SUMPRODUCT(--ISNUMBER(FIND(criteria,range))) for contains matches. Pick the formula that matches the text comparison you need.

Why does COUNTIF ignore upper and lower case?

COUNTIF compares text without regard to case. That is why blue and BLUE return the same count. If case matters, use EXACT for full-cell matches or FIND for partial matches, then wrap the result in SUMPRODUCT so Excel can total the TRUE/FALSE results.

What formula counts exact text matches with case sensitivity?

The shortest exact-match pattern is =SUMPRODUCT(--EXACT(range,criteria)). EXACT returns TRUE for a perfect case-sensitive match and FALSE otherwise. SUMPRODUCT then adds the TRUE values after the double minus converts them to 1s, so you get a simple count without Ctrl+Shift+Enter in modern Excel.

Do I need Ctrl+Shift+Enter for case-sensitive count formulas?

Usually no, if you use SUMPRODUCT. SUMPRODUCT handles array results natively in modern Excel and is also used in older array-style formulas without special entry in many cases. If a formula is written as a plain array formula in older Excel, Ctrl+Shift+Enter may still appear in older workbooks.

What’s the difference between EXACT and FIND for counting text?

EXACT checks whether two whole text values match exactly, including letter case. FIND checks whether a smaller text string appears inside another string and returns a position number when it does. Use EXACT for exact-match counts and FIND with ISNUMBER for case-sensitive substring counts.

Why is COUNTIF returning the wrong count for text?

The most common causes are hidden spaces, nonprinting characters, numbers stored as text, and closed-workbook references. COUNTIF can also miscount strings longer than 255 characters. If the syntax is right but the total is wrong, clean the text first and confirm the source range is open and correct.