Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel failing at String VLOOKUP

I have a table that looks like this

   B   C
43 XS  6
44 S   11
45 M   16
46 L   21
47 XL  26
48 XXL 31

I've written the formula:

`VLOOKUP("S",B43:C48,2)`

It's returning a value of 21. WHY?! It should be returning 11!

update I reproduced this exact error in a different table. VLOOKUP works when the search value is a number, but consistently fails when I use strings.

like image 596
Tony Stark Avatar asked Jan 21 '11 18:01

Tony Stark


People also ask

Why is VLOOKUP not working with text?

Text values or data types do not match Another common reason for VLOOKUP failure is the difference between your lookup value and a similar value in the lookup column. In some cases, the difference is so subtle that it's hard to spot visually.

Does VLOOKUP work for strings?

Yes. VLOOKUP can search for textual values just as well as it can search for numbers. The example above would search for the product names, which are text rather than numbers.

Why VLOOKUP is not working for some cells?

Solution: If you are sure the relevant data exists in your spreadsheet and VLOOKUP is not catching it, take time to verify that the referenced cells don't have hidden spaces or non-printing characters. Also, ensure that the cells follow the correct data type.

Why is my VLOOKUP not returning the correct value?

VLOOKUP Returns a value but it is incorrect There are a number of possible reasons for this: You didn't specify whether Excel must do an Exact or Approximate match (true or false as the last criteria) You specified that Excel does an approximate match but you should have required an exact match.


2 Answers

VLOOKUP does strange things unless you specify an "exact match" with the fourth argument, like so:

=VLOOKUP("S",B43:C48,2,FALSE)

From Excel's help file:

VLOOKUP(lookup_value,table_array,col_index_num,range_lookup)

If range_lookup is TRUE, the values in the first column of table_array must be placed in ascending order: ..., -2, -1, 0, 1, 2, ..., A-Z, FALSE, TRUE; otherwise VLOOKUP may not give the correct value. If range_lookup is FALSE, table_array does not need to be sorted.

And also:

range_lookup is a logical value that specifies whether you want VLOOKUP to find an exact match or an approximate match. If TRUE or omitted, an approximate match is returned. In other words, if an exact match is not found, the next largest value that is less than lookup_value is returned. If FALSE, VLOOKUP will find an exact match. If one is not found, the error value #N/A is returned.

like image 143
e.James Avatar answered Oct 20 '22 12:10

e.James


Also, mismatching format types is causing you problems. (One cell is formatted as containing numbers, and the other is formatted as containing text). See problem/solution #2 on this page:

Solutions to Three Common Problems when Using VLOOKUP()

like image 36
peter k Avatar answered Oct 20 '22 11:10

peter k