VLOOKUP to closest match

NPK

Board Regular
Joined
Jun 5, 2008
Messages
57
I've got a vlookup function driven by the result of a simple equation.

=IF(C36="","---",VLOOKUP(C18/C39,'Engine & Configuration'!D1:G24,2,TRUE))

The issue I have is that I want the result to return the CLOSEST match, not an exact or rounded up match. For example, is my "C18/C39" equation returns a value of 1.000039, I want it to match with "1" in the array and not with 1.25. The FALSE option will not work because exact matches will be very rare.

The values in the array are not whole numbers, so I don't believe a ROUNDUP type code will help.

Thanks.
 
Last edited:

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
For example, is my "C18/C39" equation returns a value of 1.000039, I want it to match with "1" in the array and not with 1.25

That is the expected behavior of Vlookup with TRUE for the matchtype.
Provided the data in 'Engine & Configuration'!D1:G24 Is sorted by Column D ASCENDING.
 
Upvote 0
The array is sorted ascending, but the value returned is the one that relates to the next higher value than that associated with "1".
 
Upvote 0
Can you post a sample set of data that has this problem?
to include the C18 and C19, and the lookup table, and the formula...

You can use either ExcelJeanie or HTML Maker.
See the sticky post at the top of forum called "How to display your sheet on the board."
 
Upvote 0
here's an example setup...

A1 = 10
B1 = 9.99
D1 = A1/B1
E1 : =VLOOKUP(A1/B1,H:I,2,TRUE)
E2 : =VLOOKUP(D1,H:I,2,TRUE)
Book1
ABCDEFGHI
1109.991.001001e0a
2e0.25b
30.5c
40.75d
51e
61.25f
71.5g
81.75h
92i
Sheet1
 
Upvote 0
I appreciate your help. I had issues with the html programs on my server due to security restrictions. I attached screen shots.

The formula =IF(C36="","---",VLOOKUP(C18/C39,'Engine & Configuration'!D1:G24,2,TRUE)) appears in cell G28, highlighted in yellow.

PracticePPlantSheet.jpg


GearheadRatios.jpg


Again, thank you for your assistance.
 
Last edited:
Upvote 0
That is returning the correct value...
C18 = 1757
C39 = 1758
1757/1758 = 0.999431171786121
The "Closest Match" to that value in your table is 0.909090909 in Cell D12
The corresonding value in E12 is 10:11
 
Upvote 0
perhaps you have your division backwards in the formula

YOu have

=IF(C36="","---",VLOOKUP(C18/C39,'Engine & Configuration'!D1:G24,2,TRUE))

Perhaps you want

=IF(C36="","---",VLOOKUP(C39/C18,'Engine & Configuration'!D1:G24,2,TRUE))

If that's the case, then
1758/1757 = 1.000569152

In which case, the closest match is 1 in Cell D13, and formula would return from E13 1:1
 
Upvote 0
If you mean that you'd like to return the closest match, whether higher or lower, try...

=INDEX('Engine & Configuration'!E2:E24,MATCH(MIN(ABS('Engine & Configuration'!D2:D24-C18/C39)),ABS('Engine & Configuration'!D2:D24-C18/C39),0))

...confirmed with CONTROL+SHIFT+ENTER, not just ENTER.
 
Upvote 0
If you mean that you'd like to return the closest match, whether higher or lower, try...


Yes, that is what I am after. This solution did the trick. Why did this have to be confirmed with Control+Shift+Enter??

Jonmo1, thank you very much for your help. I guess the equation was doing exactly what it was supposed to be doing, but I didn't know how to ask for what I wanted it to do.

Again, thanks to both of you.
 
Upvote 0

Forum statistics

Threads
1,225,510
Messages
6,185,382
Members
453,289
Latest member
ALPOINT_AIG

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