简体   繁体   English

用于搜索行以获取特定值并获取相应单元格的公式

[英]Formula to search rows for certain value and get corresponding cells

I'm trying to write a formula to search for all cells in a certain range (a certain range in a column), get the row id of any cell that matches a certain value, then get the values (of all the cells that matched) from a different column. 我正在尝试编写一个公式来搜索某个范围内(列中某个范围内)的所有单元格,获取与某个值匹配的任何单元格的行ID,然后获取(与之匹配的所有单元格的值) )。

Something like: 就像是:

    A     B
1   ABC   123
2   DEF   456
3   GHI   789
4   ABC   100

Now what I need is to look in A1:A4 for "ABC" which will return A1 and A4, and get the value of B1 and B4. 现在,我需要在A1:A4中查找“ ABC”,这将返回A1和A4,并获得B1和B4的值。 I couldn't figure it out. 我不知道。

I know I can do this in VBA. 我知道我可以在VBA中做到这一点。 But it won't update on changing like formulas do. 但是它不会像公式那样进行更新。

For i = 2 To Excel.WorksheetFunction.CountA(Range("A:A"))
    If Range("A" & i).Value = "ABC" Then
        MsgBox Range("B" & i).Value
    End If
Next I

This code find value "ABC" in "A" column and return "B" column row value. 此代码在“ A”列中找到值“ ABC”,并返回“ B”列行值。

暂无
暂无

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

相关问题 Excel公式:列中唯一单元格的数量,IF对应的行是一定值 - Excel formula: count of unique cells in column, IF corresponding row is certain value 跳过公式中具有特定值的行 - Skipping Rows with certain value in formula 更改2个单元格的值和相应的公式值需要复制到不同的工作表中 - Changing a value of 2 cells and corresponding formula values need to be copied into different sheet 某些单元格值的未识别错​​误导致#value! MATCH公式错误 - Unidentified error with certain cells values causing #value! error with MATCH formula 如果在另一个单元格中输入了某个值,是否有一个Excel公式填充多个单元格? - Is there an Excel formula that populates a number of cells, if a certain value is entered in another cell? Excel 某些单元格组合将返回值的公式 - Excel formula where certain combinations of cells would return a value Excel 公式 如果某个值与单元格范围内的值匹配,则返回不同单元格中的相应值 - Excel Formula If a value matches a value in a range of cells then return corresponding value in a different cell Excel:获取包含某些文本或公式的单元格的单元格集合 - Excel: get cell collection of cells that contain certain text or formula 仅显示具有值的单元格并删除空白行的公式 - Formula to show only cells with a value and remove blank rows 对相应单元格不是公式的所有单元格求和 - Sum all cells for which corresponding cell is not a formula
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM