简体   繁体   English

用于检查一列中某个单元格的值是否在另一列中某个单元格的范围内并在同一行上添加一个值的公式

[英]Formula to check if the value of a cell in a column is in the range of a cell in another column and add a value on the same line

I want to find a formula to check if the value of a cell in a column is in the range of a cell in another column and then add a value comprised of another column on the same line of the matching cell you are looking for in the range, and then to be able to duplicate this formula to all the cells in the column you are testing. 我想找到一个公式来检查一列中某个单元格的值是否在另一列中某个单元格的范围内,然后在要查找的匹配单元格的同一行上添加一个包含另一列的值范围,然后能够将此公式复制到要测试的列中的所有单元格。

An example: 一个例子:

Excel示例

In this pic, I want to test if the values in column B match values from column A, when it does I want the formula to check the value on the same line of column A but on column E and add it to C column on the same line as column BI am testing. 在此图片中,我想测试B列中的值是否匹配A列中的值,当我希望公式检查A列的同一行但E列中的值并将其添加到C列时与列BI am测试相同。

Then I want to be able to duplicate this formula on all column C. 然后,我希望能够在所有列C上重复此公式。

I have this formula that I use in column C starting from C2: 我有从C2开始在C列中使用的这个公式:

=IF(COUNTIF(A2:A5,B2),E2,0)

But it does not work well and if I try to duplicate if the range changes to A3:A6, etc. 但是它不能很好地工作,并且如果范围更改为A3:A6等,如果我尝试复制,请执行以下操作。

Use another column for the result, not column C , to avoid a circular reference in the formula. 为结果使用另一列而不是C列,以避免在公式中使用循环引用。 For example you can use column D or F If you choose column D you can use this formula in cell D2 and autofill column D with it: 例如,您可以使用D列或F列。如果选择D列,则可以在单元格D2使用此公式,并使用它自动填充D列:

D2:
=C2 + IFERROR(VLOOKUP(B2, A:E, 5, 0), 0)

As per you last comment, if you want only the matched value on column E otherwise stay blank, you can have it in column C but use: 根据您的最后评论,如果只希望E列上的匹配值不为空,则可以在C列中使用它,但使用:

C2:
=IFERROR(VLOOKUP(B2, A:E, 5, 0), "")

I would use INDEX MATCH it is more efficient. 我会使用INDEX MATCH来提高效率。 And from the example it seams like you want to concatenate add one string to another not add numbers if that is the case I would do the following 从示例中可以看出,您希望将一个字符串添加到另一个字符串中而不是添加数字,如果是这种情况,我将执行以下操作

=IFERROR(C2&INDEX($E:$E,MATCH($A:$A,$B2,0)),"")

暂无
暂无

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

相关问题 将单元格中输入的值添加到同一列中的另一个单元格 - Add value entered in cell to another cell in the same column 单元格值更改时,将单元格值更改所在的列复制到相同范围的另一张工作表 - When a cell value changes, copy the column from where the cell value changed to another sheet at the same range 检查单元格值是否也在另一列中 - Check if cell value is also in another column 将列单元格值设置为动态范围内的公式Maatwebsite / Excel 2.1.0 - Set column cell value as formula in dynamic range Maatwebsite/Excel 2.1.0 Excel公式,如果一列中单元格的值保持不变,但另一列中的值发生变化,则显示给我 - Excel Formula if the value of a cell in one column stays the same but the value in another changes then show me 使用单元格值更新列范围 - Update Column Range with the cell value 如何使用公式或VBA根据来自另一列的另一个单元格值来设置单元格中的值? - How to set value in a cell based on another cell value from another column using formula or VBA? VBA - 检查单元格值是否在列中 - VBA - Check if cell value is in a column 如果第 7 列中的一个单元格等于另一个单元格中的值,则更改为另一个单元格中的值 - If a cell in Column 7 equals the value in another cell change to the value in another cell 将单元格的最后一个值复制到另一列的单元格中 - copy last value of a cell into a cell of another column
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM