return Approximate match decimal number

elsg

Active Member
Joined
Mar 16, 2013
Messages
295
How return Approximate match decimal number?
My matrix below (A1:D1)
38,5038,6039,0038,40

<tbody>
</tbody>
I fill cell --> I1 = 38,47
Result cell --> I2 ​= 38,50
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Code:
Function approx(val As Range, rng As Range) As Variant

    Dim achk As Double


    achk = 100000


    For Each cell In rng
    
        Select Case Abs(cell - val.Value)
        Case Is < achk
            achk = cell - val.Value
            approx = cell.Value
        End Select
    Next


End Function

Here's a custom function with cell ranges as inputs.
 
Upvote 0
I tried using HLOOKUP and for some reason it didn't return the expected result. It will return exact matches with :

Code:
=HLOOKUP(A2,A1:D1,1,0)

but changing that to

Code:
=HLOOKUP(A2,A1:D1,1,1)

didn't return what I expected.
 
Upvote 0
could try something like....

=INDEX(A1:D1,MATCH(I1,SMALL(A1:D1,{1,2,3,4})))
 
Upvote 0

Forum statistics

Threads
1,214,590
Messages
6,120,423
Members
448,961
Latest member
nzskater

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