Finding Closest match in a range

Jek61

New Member
Joined
Jul 30, 2020
Messages
16
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi Folks,

I am trying to return a value from a range of values closest to the input value (2.57 & 1.4 in the examples below).

I have a formula which works but has inconsistent results. The screenshot below shows the issue, when I check the formula section by section it should work.

As you can see below both sides in the index and match have the "same" resultant but the formula returns #N\A

Any assistance would be greatly appreciated.

Jek61

1712151981716.png


1712151731129.png
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Either use Xmatch, or set the match to exact match.
 
Upvote 0
Solution
Hi Fluff,

How would you do it with XMATCH? I don't believe the options within XMATCH return the "closest", only next smaller or larger. In my example below, even though 1 is smaller than the lookup val of 1.4 however, 1.5 is actually closer.

Book1
DEFGHIJK
8
9Lookup ValResultSearch array
101.4111.52
11
12
Sheet4
Cell Formulas
RangeFormula
F10F10=XLOOKUP(E10,H10:J10,H10:J10,,-1)
 
Upvote 0
Thanks,

exact doesn't work and my version of excel does't have Xmatch, but thanks anyway.

Jek61
 
Upvote 0
Fluff's suggestion should work by setting match mode to 0.

Book1
ABCDEFGHIJKLM
1
22.51.81.30.90.80.60.550.275
3
4
5
61.41.3
7
8
Sheet4
Cell Formulas
RangeFormula
C6C6=INDEX(E2:L2, MATCH(MIN(ABS(E2:L2-B6)), ABS(E2:L2-B6), 0))


EDIT: You're hardcoding the 2.57 in the second formula.
Screen Shot 2024-04-03 at 9.25.09 AM.png
 
Upvote 0
Thanks Fluff and Cubist now works perfectly.

I just struggled to understand why the match failed having a matching value.

Cheers

Jek61
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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