How to compare two cells with case sensitivity in Excel
Formula (Excel and Google Sheets)
=EXACT(A2,B2)Use =EXACT(A2,B2). It returns TRUE only when the two texts match exactly, capitals included; the = sign ignores case.
- Result on the example
- one result per row in
C2, filled down toC6 - Works in
- Every current version
- Google Sheets
- Same formula
See it work
The formula is already in C2, filled down to C6. Change any input and the result updates, or edit the formula to experiment.
How it works
CRM record IDs are case-sensitive: "AbCdE" and "abcde" are different records. The = operator ignores case and would call them equal. EXACT compares character by character, capitals included, and returns TRUE or FALSE.
=EXACT(A2,B2)ResultFALSE
A2"0015g00000AbCdE"The value in A2.
B2"0015g00000abcde"The value in B2.
EXACT(A2,B2)FALSEEXACT: TRUE if two texts match exactly, including case.- text1
A2"0015g00000AbCdE" - text2
B2"0015g00000abcde"
- text1
In Google Sheets
The same formula works in Google Sheets: =EXACT(A2,B2). We ran it in Google Sheets mode on the same data and it returns the same results.
Other ways to do it
Each one was run on the same example sheet.
| Formula | Result | When to use it |
|---|---|---|
| =A2=B2 | TRUE, TRUE, TRUE…Different result | The usual comparison, for when case doesn't matter. Every row is TRUE, because = ignores case. |
| =IF(EXACT(A2,B2),"Match","Case differs") | Case differs, Match, Case differs…Different result | Labels instead of TRUE and FALSE. Shows "Match" or "Case differs". |
Common mistakes
- EXACT counts spaces, so "ABC " and "ABC" don't match. TRIM both sides if spaces don't matter.
- COUNTIF, MATCH, VLOOKUP and XLOOKUP all ignore case. For a case-sensitive lookup, combine them with EXACT (see the FAQ).
Try it yourself
Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.
Compare two cells with case sensitivity
C2, check whether the two IDs match exactly, including upper and lower case, and fill down to C6.Questions
How do I do a case-sensitive lookup?
Look up TRUE in an EXACT test: =XLOOKUP(TRUE,EXACT(A2,$B$2:$B$6),$B$2:$B$6,"Not found").
How do I count exact, case-sensitive matches?
Use =SUMPRODUCT(--EXACT($B$2:$B$6,A2)).
Checked by running on 2026-10-30: every formula and result on this page was calculated by the Spreadsheet Practice formula engine, in both Excel and Google Sheets modes.