lookup closest match

Duritz

Board Regular
Joined
Apr 28, 2005
Messages
226
Hi - if I want to lookup a value in a list, and return the closest match to it, how do I do it?

Example - I want to find the closest match to the value 1600 in this list -

1000
1250
2350
4000
8500


So, the closest match is 1250. How do I return this value?
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Hi,

Try:
Code:
=LOOKUP(1600,{1000,1250,2350,4000,8500})

and you can change 1600 to a cell reference (e.g. A1) and {1000,1250,2350,4000,8500} to a table array (e.g. B1:B100).

Regards
Jon
 
Upvote 0
Yeah but that will always match to the closest value BELOW the value in question, won't it? So, if the value to lookup was 1600, and the array was -

1100
1650
2000

wouldn't it return 1100 as the closest? What I need is the closest value in that array.
 
Upvote 0
Hmmm yes, I seem to have missed the point. Do you need a singluar formula or could you do it in steps? Stepped approach as follows:
Book4
BCDEFGH
231600211005001650
243165050
25850
261100
271650
281900
Sheet1


Or for an ugly singluar formula:
Code:
=IF(ABS($B$23-MIN(IF(B25:B28>B23,B25:B28)))<ABS($B$23-MAX(IF(B25:B28<B23,B25:B28))),MIN(IF(B25:B28>B23,B25:B28)),MAX(IF(B25:B28<B23,B25:B28)))
Confirmed with Ctrl+Shift+Enter :biggrin:

Regards,
Jon
 
Upvote 0
If your comparison values A1:A5 and you want to find the closest match to a value in B1 try

=INDEX(A1:A5,MATCH(MIN(ABS(B1-A1:A5)),ABS(B1-A1:A5),0))

confirmed with CTRL+SHIFT+ENTER
 
Upvote 0
Here's another way...

=INDEX(A2:A100,MATCH(MIN(ABS(A2:A100-B2)),ABS(A2:A100-B2),0))

...where B2 contains the value of interest, such as 1600. Note that the formula needs to be confirmed with CONTROL+SHIFT+ENTER. Adjust the range accordingly.

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,215,329
Messages
6,124,301
Members
449,149
Latest member
mwdbActuary

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