我有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
答案 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)