简体   繁体   中英

Sorting a table that another excel sheet uses causes different VLOOKUP results

I'm creating a dashboard in Excel 2010 that uses the VLOOKUP function to call another sheet's values.

The equation I'm using is this:

=VLOOKUP(L$1,Sheet_B!$A:$H,7,2)

L$1 asks for a unique identifier on Sheet_A , and then finds that ID on Sheet_B and then finds the corresponding data and pulls it. The problem is this:

If I do nothing to Sheet_B , I'll get a value - let's say 5 . This value is incorrect .

If I sort Sheet_B from AZ alphabetically (which doesn't change the data) I'll get a totally different value - let's say 12 - which is the correct value.

The problem is that the data that the VLOOKUP function examines hasn't changed, only how it was sorted in Sheet_B .

Is there any reason why this might happen? And more importantly, how can I fix it so I don't have to keep sorting Sheet_B every time I pull this dashboard?

If your 4th parameter equals True ( 2 in your case), VLOOKUP tries to find an approximate match, so you need the values in the first column of table_array to be placed in ascending order.

If you change it to 0 (equivalent to False ), VLOOKUP will try to find an exact match, and so will not need to be sorted.

Therefore, you should change your VLOOKUP to:

=VLOOKUP(L$1,Sheet_B!$A:$H,7,0)

You can read more in this Microsoft Office Support article. .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM