检查 Column 中是否存在 Cell 值,然后获取 NEXT Cell 的值

在检查列中是否存在单元格值之后,我需要使用 获取匹配单元格旁边的单元格的值。例如,我检查 cell A1中的值是否存在于 column B中,假设它匹配 B5,那么我想要 cell C5中的值。

为了解决问题的前半部分,我做了这个..。

=IF(ISERROR(MATCH(A1,B:B, 0)), "No Match", "Match")

成功了。然后,多亏了 关于 SO 的早期答案,我还能够获得匹配单元格的行号:

=IF(ISERROR(MATCH(A1,B:B, 0)), "No Match", "Match on Row " & MATCH(A1,B:B, 0))

所以很自然地,为了得到下一个细胞的值,我试着..。

=IF(ISERROR(MATCH(A1,B:B, 0)), "No Match", C&MATCH(A1,B:B, 0))

但是没有用。

我错过了什么?如何将列号追加到返回的行号以实现所需的结果?

807367 次浏览

Use a different function, like VLOOKUP:

=IF(ISERROR(MATCH(A1,B:B, 0)), "No Match", VLOOKUP(A1,B:C,2,FALSE))

How about this?

=IF(ISERROR(MATCH(A1,B:B, 0)), "No Match", INDIRECT(ADDRESS(MATCH(A1,B:B, 0), 3)))

The "3" at the end means for column C.

After t.thielemans' answer, I worked that just

=VLOOKUP(A1, B:C, 2, FALSE)

works fine and does what I wanted, except that it returns #N/A for non-matches; so it is suitable for the case where it is known that the value definitely exists in the look-up column.

Edit (based on t.thielemans' comment):

To avoid #N/A for non-matches, do:

=IFERROR(VLOOKUP(A1, B:C, 2, FALSE), "No Match")