# How to compare two cells with case sensitivity in Excel

Use =EXACT(A2,B2). It returns TRUE only when the two texts match exactly, capitals included; the = sign ignores case.

**Excel:** `=EXACT(A2,B2)` (Every current version)

**Google Sheets:** the same formula works.

## Example

Sample data (row 1 is the header):

| A | B | C |
| --- | --- | --- |
| ID in CRM | ID in export | Exact match? |
| 0015g00000AbCdE | 0015g00000abcde |  |
| 0033h00000XyZ12 | 0033h00000XyZ12 |  |
| 00Q8d00000LmNoP | 00Q8d00000LMNOP |  |
| 0015g00000QrStU | 0015g00000QrStU |  |
| 006Ab00000wxYZ9 | 006Ab00000WXyz9 |  |

Formula in C2, filled to C6: `=EXACT(A2,B2)`

Result: FALSE; TRUE; FALSE; TRUE; FALSE

## 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.

## Other ways

- `=A2=B2`: The usual comparison, for when case doesn't matter. (Every row is TRUE, because = ignores case.)
- `=IF(EXACT(A2,B2),"Match","Case differs")`: 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).

## 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))`.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/compare-two-cells-case-sensitive
