[英]Check if Cell value exists in Column, and then get the value of the NEXT Cell
After checking if a cell value exists in a column, I need to get the value of the cell next to the matching cell . 在检查列中是否存在单元格值之后,我需要获取匹配单元格旁边的单元格的值 。 For instance, I check if the value in cell A1
exists in column B
, and assuming it matches B5
, then I want the value in cell C5
. 例如,我检查cell A1
的值是否存在于column B
,并假设它与B5
匹配,那么我想要cell C5
的值。
To solve the first half of the problem, I did this... 要解决问题的前半部分,我这样做了......
=IF(ISERROR(MATCH(A1,B:B, 0)), "No Match", "Match")
...and it worked. ......而且它奏效了。 Then, thanks to an earlier answer on SO , I was also able to obtain the row number of the matching cell: 然后,由于早先对SO的回答 ,我还能够获得匹配单元格的行号:
=IF(ISERROR(MATCH(A1,B:B, 0)), "No Match", "Match on Row " & MATCH(A1,B:B, 0))
So naturally, to get the value of the next cell, I tried... 很自然地,为了获得下一个细胞的价值,我试着......
=IF(ISERROR(MATCH(A1,B:B, 0)), "No Match", C&MATCH(A1,B:B, 0))
...and it doesn't work. ......它不起作用。
What am I missing? 我错过了什么? How do I append the column number to the row number returned to achieve the desired result? 如何将列号附加到返回的行号以获得所需的结果?
使用不同的函数,如VLOOKUP:
=IF(ISERROR(MATCH(A1,B:B, 0)), "No Match", VLOOKUP(A1,B:C,2,FALSE))
After t.thielemans' answer , I worked that just 在t.thielemans的回答之后 ,我就这样做了
=VLOOKUP(A1, B:C, 2, FALSE)
works fine and does what I wanted, except that it returns #N/A
for non-matches; 工作正常,做我想要的,除了它返回#N/A
非匹配; 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): 编辑 (根据t.thielemans的评论):
To avoid #N/A
for non-matches, do: 为避免不匹配的#N/A
,请执行以下操作:
=IFERROR(VLOOKUP(A1, B:C, 2, FALSE), "No Match")
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. C列末尾的“3”表示C列。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.