EXCEL:Vlookup和Match Function - 获取它旁边的单元格值

时间:2017-10-20 03:45:44

标签: excel match cell vlookup

我有2张。一个用于子表,另一个用于主表。我需要从主表中的主表中获取master_id。

正如您在下面所看到的,使用我从Excel: Check if Cell value exists in Column, and then get the value of the NEXT Cell得到的公式,它对我不起作用。

谢谢。

子表

    A              B                C
child_id      reference_no      master_id
1             2017001           =IF(MATCH(B2,master.B2:B15,1), "NO MATCH", VLOOKUP(B2,master.A2:B15,2,0))
2             2017002           NO MATCH

主表

    A             B
master_id     reference_no
a1            2017002
a2            2017003

2 个答案:

答案 0 :(得分:1)

您尝试执行的操作的问题是VLOOKUP在第一列中搜索键,然后选择返回该列中的值或右侧的列。但是,您的Master表格会将其向后移动,其中包含B列中的键和列A中所需的值。

我可能会建议您重构主电子表格,如下所示:

主表

A             B
reference_no  master_id
2017002       a1
2017003       a2

然后,您可以在子电子表格的第C栏中输入以下公式:

=IFERROR(VLOOKUP(B2,master.A2:B10,2,FALSE),"Not found")

如果您不能/不想更改主电子表格,则有解决方法,但公式比上面的更复杂,q.v。这里:

https://superuser.com/questions/645039/excel-vlookup-by-second-column-using-table-name-as-range

答案 1 :(得分:1)

INDEX返回表格中的特定行。

MATCH返回表格中值的位置。

您想要一起使用它们:

IndexMatch