Formula for closest number

GerryZ

Well-known Member
Joined
Jul 4, 2014
Messages
1,224
Office Version
  1. 365
Platform
  1. Windows
Hello everybody
I need a formula in D2 that find th closest number (criteria number in D1)
esemple if in D1 is 9 should give me back 11 but if in D2 i digit 5 it should give me 4
thank yu for your help



Book1
ABCD
11CRITERIA6
24RESULT5
35
49
511
615
718
819
Foglio1
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
See (a) and (b) of post #19...
hello Aldin i tried both of your formulas they solve the problem when I ve two numbers close es. 3-4-5 but now I ve another Problem
because I need not only < or > than criteria but both numbers < and > than CRITERIA
that's why i will use NARAYANK991 that's is more specific for my case


=INDEX(List,MATCH(MIN(ABS(IF(List<>CRITERION,List) - CRITERION)),ABS(IF(List<>CRITERION,List) - CRITERION),0))

Thank you Aldin anyway for your help
 
Upvote 0
hello Aldin i tried both of your formulas they solve the problem when I ve two numbers close es. 3-4-5 but now I ve another Problem
because I need not only < or > than criteria but both numbers < and > than CRITERIA
...

No idea what you are talking about. The suggestions I made deliver you two numbers one closest from left (or from above) and one closest from right (or from below).
 
Upvote 0
No idea what you are talking about. The suggestions I made delivers you two numbers one from left (or from above) and one from right (or from below).
Yes is clear, your formulaS work great but I need only ONE formula that try to guess which is the closest frome above and below
 
Upvote 0
Yes is clear, your formulaS work great but I need only ONE formula that try to guess which is the closest frome above and below

Ok; What do you expect to see as result if:

Row\Col
A​
B​
C​
D​
1​
1
CRITERIA
-3
2​
2
RESULT
3​
-3
4​
4
5​
5
6​
6
7​
7
8​
8
 
Upvote 0
I don't have negative numbers
any way in this case will be number 1
 
Upvote 0
Hi Gerry.

1) Is your list always in strictly ascending order?
2) Are there ever any duplicates in the list?
3) Is there an upper bound on the size of the values in the list, e.g. 9, 99, 999?

Regards
 
Upvote 0
Hi Gerry.

1) Is your list always in strictly ascending order?
2) Are there ever any duplicates in the list?
3) Is there an upper bound on the size of the values in the list, e.g. 9, 99, 999?

Regards

1) ascending ordere YES
2) not dulicates
3) YES can be any numer from 1 to 10000000000
thank you!
 
Upvote 0
I found another way
that return above and belove closest number that is exactly what i needed
thank you everybody for the help the Thread is closed
:)



Book1
ABCD
12CRITERIO19
23RISULTATO21 - 18
34
46
511
615
718
819
921
1035
1136
1254
1362
1475
1578
1682
Foglio1
Cell Formulas
RangeFormula
D2{=INDEX(list,MATCH(MIN(ABS(IF(list>D1,list)-D1)),ABS(IF(list>D1,list)-D1),0))&" - "&INDEX(list,MATCH(MIN(ABS(IF(list)-D1)),ABS(IF(list)-D1),0))}
Press CTRL+SHIFT+ENTER to enter array formulas.
Named Ranges
NameRefers ToCells
list=Foglio1!$A$1:$A$16
 
Upvote 0

Forum statistics

Threads
1,216,494
Messages
6,130,977
Members
449,611
Latest member
Bushra

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