问题
I have the following Excel spreadsheet:
A B C D E F G H I
1 Search Criteria: Prod.B
2 Column: 2
3 Prod.A Prod.B Prod.B Prod.C Prod.C Prod.D
4
5
Currently I use the following formula in Cell C2
to get the column of the search criteria in Cell C1
in the Range D3:I3
.
=MATCH(C1,D3:H3,0)
All this works perfectly.
However, as you can see with the formula above I get back the first column number in which the search criteria appears.
What do I need to change in the formular to get the last column number in which the search criteria appears? (In the example above it would be 3)
回答1:
=MAX(IF(D3:I3=C1,COLUMN(D3:I3)-3))
Or:
=MATCH(2,1/(D3:I3=C1))
Enter both as array through CtrlShiftEnter
Alternatively:
=LOOKUP(2,1/(D3:I3=C1),COLUMN(D3:I3)-3)
It should still be an array formula but you don't have to enter it as such.
来源:https://stackoverflow.com/questions/58114477/get-the-last-column-number-of-a-search-criteria-in-a-defined-range-if-values-ar