tags:

views:

61

answers:

3

Does anyone know how to do a case sensitive vlookup with excel?

A: 

My first thought is to use the EXACT() function to test the result of the vlookup:

=IF(EXACT(VLOOKUP(A2,$C$2:$C$4,1,FALSE),A2),VLOOKUP(A2,$C$2:$C$4,1,FALSE),0)

Where A2 = the value you wish to look up and C2:C4 is the range containing the values to look up.

This would return the result of the vlookup and confirm that it matched the case of the value you wish to look up. It would return the vlookup result if they match case, or 0 otherwise.

EDITED

Actually this answer wouldn't work. If your list contained "Bob" and "bob" it would find the first one and only test that. Sorry, I didn't think of that.

Nicholosophy
I tried that yesterday, and Jenny said it didn't work, but maybe you'll have better luck than I did.
LittleBobbyTables
+1  A: 

it seems to be a feature of vlookup that case does not matter - so Bob is the same as bob. You could use code() to convert to ASCII and lookup on code. This would make your lookup more complicated, and code() only returns the code for the first item in the string.

alastair harris
A: 

If the value you are returning is a number and not text, and if the first column of your lookup_table is unique ('bob' doesn't appear more than once), then you can use an array formula like this

=SUM(EXACT(A3:A6,"bob")*(B3:B6))

Enter with Control+Shift+Enter, not just enter. It sums everything in B3:B6 where A3:A6 is exactly "bob". Since there's only one "bob", it's only summing one cell. Because it uses SUM, returning strings won't work.

If 'bob' appears more than once, it will sum all the values, which you probably don't want.

Update

If the value you are looking up is not a number, you could use an array formula to find the row, then wrap an INDEX function around it. Assume your data is A3:B6 and you want to pull data out of column B based on an exact match in column A.

=INDEX(A3:B6,SUM(EXACT(A3:A6,"bob")*(ROW(B3:B6)))-2,2)

Enter with CSE. The SUM portion returns the row where "bob" is found. You have to subtract 2 from it because the data starts in A3 (subtract one less than the row where the data starts). The INDEX function uses that row and pulls from column B.

Dick Kusleika
nope i have letters
i am a girl
@dick thank you. i have one column on one worksheet, but the other column (the column that i am matching on in another worksheet, so ur formula does not work in my case)
i am a girl
Nor would VLOOKUP, case-sensitive or not. You might consider editing your question with more info about how the data is laid out. I'm sure there's a solution.
Dick Kusleika
@dick actually vlookup does work across multiple worksheets
i am a girl
It does? That's a new one on me. Can you give me an example of that?
Dick Kusleika
@dick try it. what example do u need
i am a girl
Any working example will be fine. This formula =VLOOKUP(1,Sheet1:Sheet3!A3:B7,3,FALSE) returns a #VALUE error. Since the second argument has to be a contiguous range, I'm not sure how to references ranges on multiple sheets.
Dick Kusleika