简体   繁体   English

如何使用VLookUp Excel函数从结尾处的lookup_value中搜索值?

[英]How to search from a value using VLookUp Excel function from lookup_value starting at end?

我有以下数据

I used below Vlookup formula to pick my desired data 我使用下面的Vlookup公式来选择所需数据

=VLOOKUP(100,PersonDetails,2,FALSE)

Ideally i need the formula to fetch Adress1 value (abc) for the key 100(lookup_value) from the named range(PersonDetails) but the formula doesn't seems to get correct data ( #N/A is displayed as result). 理想情况下,我需要公式来从命名范围(PersonDetails)中获取键100(lookup_value)的 Adress1值(abc) ,但是该公式似乎无法获取正确的数据(显示#N / A作为结果)。 Any workaround for this? 任何解决方法?

Note : PersonDetails is a named range and not a table. 注意:PersonDetails是一个命名范围,而不是一个表。

Unfortunately VLOOKUP assumes the lookup column is the first column of the range, so unless you are able to change the order of the columns you can't do what you want. 不幸的是,VLOOKUP假定查找列是范围的第一列,因此,除非您能够更改列的顺序,否则您将无法做自己想要做的事情。

The alternative (I wouldn't call it a workaround, it's generally argued that it is better) is to use MATCH and INDEX 替代方法(我不会称其为解决方法,通常认为这样更好)是使用MATCH和INDEX

The formula would look like this:- 公式如下所示:

=INDEX(PersonDetails,MATCH(100,INDEX(PersonDetails,,5),0),2)

In reverse order:- 反向:

The second INDEX specifies the fifth column of the range (Key). 第二个INDEX指定范围(键)的第五列。

The MATCH looks up the value 100 in the Key column and finds it in the first row of data. MATCH在“键”列中查找值100,并在数据的第一行中找到它。

The first INDEX returns the value in the first row and second column of the range (or the second row if the range includes the headers) (abc). 第一个INDEX返回范围的第一行和第二列中的值(如果范围包括标题,则返回第二行)(abc)。

You could add a column at the start with the key again, then just hide it, and keep your formula and table layout. 您可以在键的开头再次添加一列,然后将其隐藏,并保留公式和表格的布局。 But the previous answer is far better. 但是以前的答案要好得多。 Eg B5 formula =G5, then include column B in your range. 例如,B5公式= G5,然后在您的范围内添加B列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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