I have a table array $E$14:$G$851
. Column E just contains unique identifiers, lets say a/b/c/d etc, column F contains hundreds of numbers all less than or equal to 20 and column G contains the values I need returned.
I need a formula which will search for the unique identifier in column E, and then search UP column F and find me the FIRST value that is LESS THAN the column F result and use that result to return the adjacent value in column G.
So if I had searched for "g", the formula would then search UP column F for the first number LESS THAN 16. This would be "d" with 12. the formula would then return 25010 from column G.
I've been searching for an answer to this for weeks and haven't found any examples of excel searching an array from bottom to top. I'd strongly prefer to not change the data layout (such as flipping it).
You can get it with the following array formula (press CTRL+SHIFT+ENTER after entering it in the cell:
=INDEX(C:C,MAX(IF(OFFSET($B$1,0,0,MATCH(E1,A:A,0)-1)<VLOOKUP(E1,A:B,2,FALSE),ROW(OFFSET(B1,0,0,MATCH(E1,A:A,0)-1)),"")))
How it works:
OFFSET($B$1,0,0,MATCH(E1,A:A,0)-1)
- gets a reference of B column over the ID being searchedIF(OFFSET(...)<VLOOKUP(E1,A:B,2,FALSE),ROW(OFFSET(...),"")
- returns an array containing row number for rows having value in B less then row searched and blank for the othersMAX(IF(...))
- select maximum value (last row with value in B fullfilling criteria=INDEX(C:C,MAX(...))
- select cell in column CCollected from the Internet
Please contact [email protected] to delete if infringement.
Comments