Reputation: 881
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.
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. I couldn't figure it out.
I know I can do this in VBA. But it won't update on changing like formulas do.
Upvotes: 1
Views: 1444
Reputation: 11
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.
Upvotes: 1