Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Return first cell in range between target values

I want to get the value of the first cell in a range that is between two values. The best I can do is get the first cell that is either smaller or larger than a value. I want the first cell that is BOTH larger than a value AND smaller than an other value. This did not work (because it's only 1 criteria):

{=INDEX(A1:A10,MATCH(TRUE,A1:A10<B1,0))}

note: A1:A10 is the rage of values and B1 is the comparison

I tried:

{=INDEX(A1:A10,MATCH(TRUE,and(A1:A10<B1,A1:A10>B2),0))}

but it did not work.

Thank you for your help.

like image 663
Touten Avatar asked Apr 28 '26 03:04

Touten


1 Answers

Try this:

{=INDEX(A1:A10,MATCH(1,(A1:A10<B1)*(A1:A10>B2),0))}

Please note, that it is an array formula, therefore you don't have to write the {}, but when you enter the formula, do this with Ctrl+Shift+Enter.

like image 130
MGP Avatar answered Apr 30 '26 17:04

MGP



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!