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