简体   繁体   English

检查值是否包含在另一列中,然后根据该值获取值 (Excel)

[英]Check if value contains in another column and then get value based on that (Excel)

I have three columns in Excel sheet.我在 Excel 工作表中有三列。 For example:例如:

在此处输入图像描述

Now what I want to achieve is that when ID in D column matches ID in A column, then VALUE in B column is copied to E column next to matching ID.现在我想要实现的是,当 D 列中的 ID 与 A 列中的 ID 匹配时,B 列中的 VALUE 将被复制到匹配 ID 旁边的 E 列。

For example: ID 4 (in D column) should have value 11 (in E column [E2]) ID 7 (in D column) should have value 77 (in E column [E6])例如:ID 4(在 D 列中)的值应为 11(在 E 列 [E2] 中) ID 7(在 D 列中)的值应为 77(在 E 列 [E6] 中)

Use INDEX and MATCH .使用INDEXMATCH Type this formula into E2 and drag it down:将此公式键入 E2 并将其向下拖动:

=INDEX($B$2:$B$9,MATCH(D2,$A$2:$A$9,0))

MATCH will look up the row number in column A and INDEX delivers the corresponding value from column B. MATCH将查找 A 列中的行号, INDEX提供 B 列中的相应值。

So I solved this.所以我解决了这个问题。 I used the following formula in E cell:我在 E 单元格中使用了以下公式:

=LOOKUP(D2,$A$2:$A$9,$B$2:$B$9) =查找(D2,$A$2:$A$9,$B$2:$B$9)

and then I dragged this all the way to the end of E column (E9)然后我将它一直拖到 E 列 (E9) 的末尾

You could use the below:您可以使用以下内容:

=IFERROR(VLOOKUP(D2,$A$2:$B$9,2,0),"Value not found")

In case of missing value you will get Value not found如果缺少值,您将得到Value not found

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM