问题
I need to lookup the value of something in a table and then return the row that it's in. The value can be in any column, so Match doesn't seem ideal. What's the best way to do this?
As an example, say the table has 2 columns. Column 1 has A, B, C, D. Column 2 has E, F, G, H. I want to find out which row "G" is in, so I want to somehow return "3" without knowing beforehand that "G" is in column 2.
回答1:
Please try:
=IFERROR(MATCH("g",A:A,0),MATCH("g",B:B,0))
and so on if more columns.
回答2:
Assuming your data isn't duplicated, given this layout:
Column 1 Column 2
A E
B F
C G
D H
,this formula:
=MAX(IF(A1:B5="G",ROW(A1:B5),0))
will do what you want. In this case it would return 4. It also has the ability to work with an infinte number of columns (if nothing is duplicated, also a lot of columns might impact performance)
It's an array formula so you have to confirm it with Ctrl + Shift + Enter
来源:https://stackoverflow.com/questions/23664203/excel-lookup-in-multiple-column-array-return-row