Searching an array from bottom to top

Leon Woodward

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.

example

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).

Máté Juhász

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 searched
  • IF(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 others
  • MAX(IF(...)) - select maximum value (last row with value in B fullfilling criteria
  • =INDEX(C:C,MAX(...)) - select cell in column C

enter image description here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Searching from Bottom to Top in Python

From Dev

Searching from Bottom to Top in Python

From Dev

slideDown from bottom to top (and not from top to bottom)

From Dev

Java array stack, printing contents of stack from top to bottom

From Dev

print 2d array diagonally from bottom to top

From Dev

Html, Place items from an array in the top/bottom <div> based on a property

From Dev

Scroll ListView from bottom to top

From Dev

Align div from bottom to top

From Dev

Load images from bottom to top?

From Dev

Visitor pattern (from bottom to top)

From Dev

Linear Gradient from bottom to top

From Dev

Rotating Div from bottom to top

From Dev

Position divs from the bottom to the top

From Dev

foreach fills from bottom to top

From Dev

A white place from top to the bottom

From Dev

Scroll Reveal from Top to Bottom

From Dev

jquery sliding from top to bottom

From Dev

Visitor pattern (from bottom to top)

From Dev

Fading an Image from Top to Bottom

From Dev

Load images from bottom to top?

From Dev

Read From Bottom to Top Batch

From Dev

A white place from top to the bottom

From Dev

foreach fills from bottom to top

From Dev

Linear Gradient from bottom to top

From Dev

How to fade in from bottom to top

From Dev

Android Layout Animations from bottom to top and top to bottom on ImageView click

From Dev

Android Layout Animations from bottom to top and top to bottom on ImageView click

From Dev

JS+CSS How to display images from an array from top right to bottom left

From Dev

Searching a string from an array of strings