Find closest value in a cell range (No Arrays!)
Hi All,
I need help finding creating a formula the returns the closest number in a range in.
For example, I type 12 against a list of {10,15,25} and it would return 12. If i type in 13, it would return 15. I have found a solution using array formulas but would like to avoid that if possible.
Posted Aug 6, 2014, 10:49 PM UTC
06
I'm assuming you meant to say it should return 10?
The formula I use is:
=IF(ABS(B1-INDEX(A1:A3,MATCH(B1,A1:A3,1)))<ABS(INDEX(A1:A3,MATCH(B1,A1:A3,1)+1)-B1),INDEX(A1:A3,MATCH(B1,A1:A3,1)),INDEX(A1:A3,MATCH(B1,A1:A3,1)+1))
You will need to add in the lower and upper bound conditions with if statements yourself. I deliberately did not include it to make the core of the formula a little clearer.
This doesn't work when the value is less than 10 and greater than 25 in your example btw.
I know, I mentioned that in my 4th bullet point. He/she just needs to add 2 if() statements in front. I left it out to make the core of the formula more clear, it's a little messy already.
[deleted]
Solution Verified
You have awarded one point to bgritzut