I'm not sure if you're looking for the 2 closest values or the smallest difference between the 2 closest values.
If your data is in A1:A10
NOTE: Array formulas are committed with CTRL+SHIFT+ENTER, instead of just ENTER.
This ARRAY FORMULA (broken into segments) returns
the smallest difference between the two closest values:
C1:
=SMALL(SMALL($A$1:$A$10,ROW($A$1:INDEX($A:$A,COUNT(A1:A10)-1))+1)
-SMALL($A$1:$A$10,ROW($A$1:INDEX($A:$A,COUNT(A1:A10)-1))),1)
If you want the 2 values:
This ARRAY FORMULA
-Sorts the range in ascending order
-Calculates the differences between those values
-Returns the smallest value of the pair with the smallest difference
C2:
=INDEX(SMALL($A$1:$A$10,ROW($A$1:INDEX($A:$A,COUNT(A1:A10)-1))),
MATCH(SMALL(SMALL($A$1:$A$10,ROW($A$1:INDEX($A:$A,COUNT(A1:A10)-1))+1)
-SMALL($A$1:$A$10,ROW($A$1:INDEX($A:$A,COUNT(A1:A10)-1))),1),
SMALL($A$1:$A$10,ROW($A$1:INDEX($A:$A,COUNT(A1:A10)-1))+1)
-SMALL($A$1:$A$10,ROW($A$1:INDEX($A:$A,COUNT(A1:A10)-1))),0))
and this REGULAR FORMULA returns the second value;
C3: =LARGE(A1:A10,RANK(A4,A1:A10)-1)
Using your posted data:
C1 returns 1
C2 returns 152
C3 returns 153
Is that something you can work with?
Bookmarks