Lookup

Case-sensitive lookup in Excel

Lookup functions treat "abc" and "ABC" as the same. EXACT compares text with case, so wrap it in MATCH or XLOOKUP.

All Excel versions (Ctrl+Shift+Enter in 2019 and older)

The formula

ExcelExcel
=INDEX(B2:B4,MATCH(TRUE,EXACT(A2:A4,B6),0))
In E2 → 10%
Excel 365Excel
=XLOOKUP(TRUE,EXACT(A2:A4,B6),B2:B4)
In E3 → 10%
Google SheetsGoogle Sheets
=ARRAYFORMULA(INDEX(B2:B4,MATCH(TRUE,EXACT(A2:A4,B6),0)))
In E4 → 10%
✓ Tested. All 2 Excel results in this example were recalculated in LibreOffice Calc 25.2 and matched the values shown. 1 result for formulas tagged Google Sheets was checked with a reference implementation of the documented behavior, because LibreOffice can't run that function.

Worked example

Paste the data below into a blank sheet starting at cell A1 (or download the cheat sheet, where every example is set up). Highlighted cells hold the formulas and show the expected results.

ABCDE
1CodeDiscount
2save105%10%
3SAVE1010%10%
4Save1015%10%
5
6CodeSAVE10

How it works

EXACT(A2:A4,B6)
TRUE only where the code matches with the same upper/lower case.
MATCH(TRUE,…,0)
Position of the first TRUE.
INDEX(B2:B4,…)
Returns the discount at that position.

Common errors and fixes

Why does the formula return #N/A?

No exact-case match. Remember EXACT also treats extra spaces as different.

Always returns the first row?

In Excel 2019 or older, enter with Ctrl+Shift+Enter.

Does this work in Google Sheets?

Yes. Use the formulas tagged "Google Sheets" on this page; formulas tagged only "Excel" use Excel-specific syntax.