Finding closest value in a non sorted column (equal or greater)

cidfidou

Board Regular
Joined
Jan 19, 2009
Messages
163
Hi Excel Masters,

i am trying to come up with a formula that can give me the closest value in a non sorted column (equal or greater). I can not use a simple match as my column can not be sorted.. I am using the below formula but doesnt work all the time...

Any help would be greatly appreciated!!!

SLrange = my rage
AJ20 the lookup value

=INDEX(SLrange,MATCH(MIN(ABS(SLrange-AJ20)),ABS(SLrange-AJ20),0))
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hi cidfidou,

This should be an array formula, try press F2 on the cell and press Ctrl+Shift+Enter (you'll see curly brackets created for array formula)
 
Upvote 0
Hi Exceldevs,

thanks for answer... I forgot to put the curly bracket in my post but not in my excel file... below an is an example of what I am trying to achieve

RangeLookup ValueResult
10.31
70.41
60.81
312
21.12
41.52
534
5.86

<colgroup><col><col><col><col></colgroup><tbody>
</tbody>
 
Upvote 0
Interesting. I would've thought there'd be a more concise solution than this, though I can't come up with it if there is. Again, array-entered:

=INDEX(SLrange,MATCH(MIN(IF(SLrange-AJ20>0,SLrange-AJ20)),SLrange-AJ20,0))

Regards
 
Upvote 0
Or


A
B
C
D
1
Range​
Lookup Value​
Result​
2
1​
0,3​
1​
3
7​
0,4​
1​
4
6​
0,8​
1​
5
3​
1​
2​
6
2​
1,1​
2​
7
4​
1,5​
2​
8
5​
3​
4​
9
5,8​
6​
10
9​
Not Found​


Array formula in D2 copied down
=IFERROR(SMALL(IF($A$2:$A$8>C2,$A$2:$A$8),1),"Not Found")

confirmed with Ctrl+Shift+Enter, not just Enter

M.
 
Upvote 0
REMARK: in the thread title you wrote equal or greater, but the expected results in #3 consider only values greater than.

Could you clarify?

M.
 
Upvote 0
Thank you so much Marcelo.. Amazing Formula...

U r right... I made a mistake in my table in #3..
it should have been as below and works perfectly if we had a "=" ={IFERROR(SMALL(IF($A$2:$A$8>=C2,$A$2:$A$8),1),"Not Found")
}

RangeLookup ValueResult
10.31
70.41
60.81
311
21.12
41.52
533
5.86

<colgroup><col style="width:48pt" span="4" width="64"> </colgroup><tbody>
</tbody>
 
Upvote 0

Forum statistics

Threads
1,215,004
Messages
6,122,656
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top