Excel thinks “ABC123” and “abc123” are the same. Usually that’s helpful, but not when product codes, passwords, IDs or part numbers depend on capital letters. Here’s how to make lookups case-sensitive using the EXACT function.
The problem
| A | B | |
|---|---|---|
| 1 | Code | Product |
| 2 | ab-10 | Blue pen |
| 3 | AB-10 | Black marker |
| 4 | Ab-10 | Red pencil |
=XLOOKUP("AB-10", A2:A4, B2:B4)
Result: Blue pen ❌ (the first match, ignoring case). VLOOKUP, XLOOKUP, MATCH, COUNTIF and SUMIF all ignore case.
Meet EXACT
=EXACT(text1, text2)
Returns TRUE only if both texts are identical, including upper and lower case.
=EXACT("AB-10","AB-10")→ TRUE=EXACT("AB-10","ab-10")→ FALSE
Case-sensitive XLOOKUP
=XLOOKUP(TRUE, EXACT(A2:A4, "AB-10"), B2:B4, "Not found")

Result: Black marker ✅
How it works: EXACT(A2:A4,"AB-10") checks every code and returns {FALSE; TRUE; FALSE}. XLOOKUP then finds the first TRUE and returns the product from that row.
Use a cell instead of typing the code: =XLOOKUP(TRUE, EXACT(A2:A4, E1), B2:B4, "Not found")
Older Excel: INDEX and MATCH
=INDEX(B2:B4, MATCH(TRUE, EXACT(A2:A4, E1), 0))
In Excel 2019 or earlier, press Ctrl + Shift + Enter to confirm it. See INDEX and MATCH explained.
Count case-sensitive matches
COUNTIF ignores case, so use SUMPRODUCT with EXACT:
=SUMPRODUCT(--EXACT(A2:A100, E1))
The -- turns TRUE/FALSE into 1/0 so they can be added up.
Sum case-sensitive matches
=SUMPRODUCT(EXACT(A2:A100, E1)*C2:C100)
Adds up column C only where the code matches exactly.
Find case-sensitive duplicates
Put this in a helper column next to your list:
=IF(SUMPRODUCT(--EXACT($A$2:$A$100, A2))>1, "Duplicate", "")
Excel’s built-in Remove Duplicates ignores case, so this helps when “AB-10” and “ab-10” are truly different items.
Return all case-sensitive matches
=FILTER(A2:C100, EXACT(A2:A100, E1), "None")
Learn more in UNIQUE, SORT and FILTER.
Other case-sensitive functions
| Case-sensitive | Not case-sensitive |
|---|---|
| EXACT, FIND, SUBSTITUTE | VLOOKUP, XLOOKUP, MATCH, COUNTIF, SUMIF, SEARCH, the = operator |
For example, =ISNUMBER(FIND("AB",A2)) checks if A2 contains capital “AB”, while SEARCH would also match “ab”.
Google Sheets
EXACT works the same way. In Google Sheets, wrap array formulas in ARRAYFORMULA() if needed:
=XLOOKUP(TRUE, ARRAYFORMULA(EXACT(A2:A4, E1)), B2:B4)
When case-sensitive lookups matter
- Product and part codes: some systems use “AB-10” and “ab-10” for different items.
- Short IDs and voucher codes: codes like “x7Kp2” and “X7KP2” may be different records.
- Usernames imported from other systems where upper and lower case were treated as different.
- Checking data entry: finding “bahrain” vs “Bahrain” before a report, so totals are not split.
If case does not really matter in your data, it is often better to clean it instead: convert everything to one style with UPPER() or PROPER(), then use a normal lookup.
Common mistakes
- Forgetting TRUE as the lookup value. In
XLOOKUP(TRUE, EXACT(...), ...), Excel looks for the TRUE produced by EXACT, so the first argument must be TRUE, not the code. - Extra spaces. EXACT treats “AB-10 ” (with a space) as different. Use
TRIM()on both sides if your data is messy. - Whole-column references in older Excel. In INDEX/MATCH versions that need Ctrl + Shift + Enter, use a fixed range like A2:A1000, not A:A, to keep the file fast.
- Expecting COUNTIF to see case. It never does. Use
SUMPRODUCT(--EXACT(range,value))to count exact-case matches.
Quick summary
- Most lookup functions ignore upper/lower case.
- Use
=XLOOKUP(TRUE, EXACT(range, value), return_range)for a case-sensitive lookup. - Use
SUMPRODUCT(--EXACT(...))to count, and FILTER + EXACT for all matches.
FAQ
Is VLOOKUP case-sensitive?
No. VLOOKUP, XLOOKUP, MATCH, COUNTIF and SUMIF all ignore case. Use EXACT inside XLOOKUP or INDEX and MATCH for a case-sensitive lookup.
How do I make XLOOKUP case-sensitive?
Use =XLOOKUP(TRUE,EXACT(A2:A100,”AB-10″),B2:B100). EXACT returns TRUE only where the case matches exactly.
How do I check if two cells match exactly, including case?
Use =EXACT(A2,B2). It returns TRUE only if the text and the capital letters are the same.
Does Google Sheets have a case-sensitive lookup?
Yes, use the same EXACT trick, for example =XLOOKUP(TRUE,EXACT(A2:A100,”AB-10″),B2:B100), or FILTER with EXACT.