If you need to perform case-sensitive look ups then you need to learn about the EXACT function.
Normal look ups in Excel are not case sensitive. To make them case-sensitive you need to use the EXACT function.
In the image below you can see that the formula in cell E3 Is returning the value for the uppercase B not the lowercase b.

The formulas in cells E4 and E5 are working as expected and they are using the EXACT function.
The EXACT function is case-sensitive. It returns TRUE if the values are identical and FALSE if they’re not.
Because we’ve used a range as the first argument each of the cells is compared to the value in the second argument and this returns a list of TRUE and FALSE results. The XLOOKUP is looking for TRUE and it finds the first match.
In the image below we can see the results of the EXACT function in cell E5 – comparing the lowercase b to the list in column A.

The TRUE entry is the second last which is the match for the lowercase b in the list in column A.
If there were more than one TRUE result the XLOOKUP would find the first TRUE.

While I would use the EXACT function formula the way you did, I would note that another way to do this is to use the CODE function instead. This formula that you posted…
.
=XLOOKUP(TRUE,EXACT(A2:A7,D4),B2:B7,””)
.
can be replaced by this one and it will work the same way…
.
=XLOOKUP(CODE(D4),CODE(A2:A7),B2:B7,””)
Thanks for that Rick.
I have never used the CODE function – I will investigate.
It simply returns the ASCII code for the given character or for the first character if more than one character. I should have pointed out that my formula would NOT work if your codes consisted of multiple characters.
Noted – âšī¸I was getting excited – it might be useful for other things.
I just wanted to follow up and show you how CODE could be used for any general lookup value. Note, however, that the formula is ridiculously long compared to your EXACT formula and I am only showing it for information purposes and not as a recommended alternative…
.
=LET(v,D2,f,LAMBDA(r,TEXTJOIN(“|”,,CODE(MID(r,SEQUENCE(,LEN(r)),1)))),XLOOKUP(f(v),MAP(A$2:A$7,LAMBDA(x,f(x))),B$2:B$7))
Thanks Rick Wow you have really embraced the new dynamic array capabilities.
Before coming to Excel, I was a Microsoft MVP for Visual Basic (not VBA) and one thing I was famous (actually, infamous) for was writing one-liner programs. The introduction of dynamic arrays and the functions to support them make writing formulas a lot like writing program code and, of course, a formula is basically a one-liner, so I am right at home with them.đ
Ahh that explains a lot – like why you are so good at VBA => because you used VB.
Agree Dynamic Arrays provide a lot more solutions that don’t need helper cells because the helper cells can be inside a LET function.
Thanks for sharing