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)
[TABLE="class: grid, width: 274"]
<tbody>[TR]
[TD="width: 64, align: right"]38,50[/TD]
[TD="width: 82, align: right"]38,60[/TD]
[TD="width: 64, align: right"]39,00[/TD]
[TD="width: 64, align: right"]38,40[/TD]
[/TR]
</tbody>[/TABLE]
I fill cell --> I1 = 38,47
Result cell --> I2 ​= 38,50
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
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,222,246
Messages
6,164,802
Members
451,917
Latest member
WEB78

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