简体   繁体   English

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

[英]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.

相关问题 Excel:检查列中是否存在单元格字符串值,并获取对该字符串的所有单元格引用 - Excel: Check if cell string value exists in column, and get all cell references to that string VLOOKUP检查单元格中是否存在值 - VLOOKUP to check if a value exists in a cell 查找数据单元格值,在列中向上移动一个单元格,在列中查找下一个数据单元格并获取下一个值 - Find data cell value, move up one cell in column, find next data cell within a column and get next value VBA - 检查单元格值是否在列中 - VBA - Check if cell value is in a column 检查SQL中是否存在excel单元格值 - check if excel cell value exists in SQL VBA如何检查单元格值是否有效和存在? - VBA How to Check if Cell Value is valid and exists? 如何在excel列中获取下一个非空单元格值 - how to get next non empty cell value in an excel column 检查“单元格”值是否存在于“列”中,并针对同一事件在同一行但不同列中返回值的总和 - Check if Cell value exists in Column and return a sum for a value in the same row but different column for each occurance 检查列中是否存在单元格值,返回同一行不同列中的值 - Check if a Cell Value exists in column, return a value in the same row but different column 获取列中最后一个单元格上方的单元格的值 - Get value of cell above last cell in column
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM