VLOOKUP returns wrong value

JWGoldfinch

Board Regular
Joined
Dec 23, 2009
Messages
50
I have a VLOOKUP that is taking the value in a cell that has "*0026" and it is returning the value in the table for the value of "00026". In this case the two are not the same values there could be either or both in the lookup table. Any Ideas of how I can ensure that if "*0026" is not in the lookup table it will return the #N/A instead of the value for "00026"
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
the limitation to a VLOOKUP is that it only returns one instant of duplicate value. It takes the first it finds and keeps that as the answer. Check your data to see if the value that is being looked up has a dupe.
 
Upvote 0
Make your lookup value like the below

"~"&A1


e.g. =Vlookup("~"&A1, B1:D5,3,0)
 
Upvote 0
It's Ok to Hijack the thread, I don't know what it does either, but it returned the results that I was looking for.
 
Upvote 0
Its a 'literal' search

Your original Vlookup query had you with *0026 as a lookup value, which is taken as a wildcard search due to the *
Now if you had a table with

Sheet1

*AB
*0026

<colgroup><col style="font-weight:bold; width:30px; "><col style="width:64px;"><col style="width:64px;"></colgroup><tbody>
[TD="bgcolor: #cacaca, align: center"]1[/TD]
[TD="align: right"]90026[/TD]
[TD="align: right"]1[/TD]

[TD="bgcolor: #cacaca, align: center"]2[/TD]

[TD="align: right"]2[/TD]

</tbody>


Excel tables to the web >> Excel Jeanie HTML 4

And you were searching for *0026 using a vlookup as =Vlookup("*0026", A1:B2,2,0) you would get a 1, as 90026 meets the criteria, that is *0026 is saying go look for anything that ends with 0026, it ignores the leading values, if you had *002*, it would search for 002 and ignore the leading and trailing characters


The Tilde (~) is used as a literal, now with the previous we were looking for a *0026, but excel did not see this so we had to tell it we really wanted it, so we use a Tilde (~), so if we had *0026 in C1, we would put ="~"&C1 which stops the * from being a wildcard so we are really search for *0026




Hope that helps
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top