Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Retrieve cell value from a sorted range when an "input" cell value is >= than the first cell in the range AND < than the next cell in the range

I’m trying to write a formula that retrieves a value from a sorted range when another cell value (the "input") is >= than the first cell in the range and < than the next value in this range (if there is a way to do it without sorting the range I’m happy with it too).

I tried using query but I can’t find a way to make it work.

This is the sheet I have:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

A (input) B
910 0
1000
4000
7000

and I would like to retrieve 0.

In this other case I would like to retrieve 4000:

A (input) B
5440 0
1000
4000
7000

I need this formula for a VLOOKUP search_key that I will use to retrieve another value from cell C =VLOOKUP(A2,B2:C5,2,FALSE), so instead of having to put the exact value I’m trying to vlookup in A2 I can get it by comparing A2 to the range.

>Solution :

=vlookup(A7,$A$1:$A$4,1,1)

or

=xlookup(A7,$A$1:$A$4,$A$1:$A$4,,-1)

Result:

enter image description here

Also you can sort directly in formula:

=vlookup(A7,sort($A$1:$A$4,1,1),1,1)

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading