Closest match insert value

strongman86

Board Regular
Joined
Feb 15, 2017
Messages
115
Office Version
  1. 2019
Platform
  1. Windows
Hi all,
Need formula in B2 that compares A2 cell value with column H values and find closest match that are either equal or lower than A2 value. Then it need to return value from corresponding column G which in this case is text (Orange). Thanks.


ABCDEFGHIJ
1Unit sizeTypeTypeType size
2280Red36
364Blue78
496Yellow108
5175Green229
620Orange300

<tbody>
</tbody>
 
Last edited:

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Book1
ABCDEFGH
1Unit sizeTypeTypeType size
2208YellowRed36
364RedBlue78
496BlueYellow108
5175YellowGreen229
620*Not Found*Orange300
Sheet1
Cell Formulas
RangeFormula
B2=IFERROR(INDEX($G$2:$G$6,MATCH(A2,$H$2:$H$6,1)),"*Not Found*")


WBD
 
Upvote 0
Or another very similar option:

=IFERROR(LOOKUP(A2,$H$2:$H$6,$G$2:$G$6),"Not Found")
 
Upvote 0
Thanks Guys.
Formula works, but it's not exactly what I'm after. Just noticed that value needed to be higher not lower as I originally described. Sorry for confusion. See below what values needed to be returned in B column.

ABCDEFGH
1Unit sizeTypeTypeType size
2280OrangeRed36
364BlueBlue78
496YellowYellow108
5175GreenGreen229
620RedOrange300


<colgroup><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
 
Upvote 0
Love it when the question completely changes ... :-|

In which case you'd be better to sort your size list in descending order:


Book1
ABCDEFGH
1Unit sizeTypeTypeType size
2280OrangeOrange300
364BlueGreen229
496YellowYellow108
5175GreenBlue78
620RedRed36
Sheet1
Cell Formulas
RangeFormula
B2=IFERROR(INDEX($G$2:$G$6,MATCH(A2,$H$2:$H$6,-1)),"*Not Found*")


WBD
 
Upvote 0
Sorry again :)
Still doesn't work. I used =IFERROR(INDEX($G$2:$G$6,MATCH(A2,$H$2:$H$6,-1)),"*Not Found*") and it returned me *Not Found* in B2 / B3 / B4 / B5 & Orange in B6.
I can't use sort as column A on my original spreadsheet is about 100 rows long where column H is as you see 6 rows.
 
Upvote 0
I can't use sort

Not sure why the number of rows would matter when sorting but, one option - which will return the first type that fits the crtieria.


Excel 2013/2016
ABCDEFGH
1Unit sizeTypeTypeType size
2280OrangeRed36
364BlueBlue78
496YellowYellow108
5175GreenGreen229
620RedOrange300
Sheet1
Cell Formulas
RangeFormula
B2=INDEX($G$2:$G$6,MATCH(TRUE,INDEX(A2<=$H$2:$H$6,0),0))
 
Upvote 0
Sorry again :)
Still doesn't work. I used =IFERROR(INDEX($G$2:$G$6,MATCH(A2,$H$2:$H$6,-1)),"*Not Found*") and it returned me *Not Found* in B2 / B3 / B4 / B5 & Orange in B6.
I can't use sort as column A on my original spreadsheet is about 100 rows long where column H is as you see 6 rows.

You only needed to sort the rows in columns G/H. However, you now have a nice alternative from FormR.

WBD
 
Upvote 0

Forum statistics

Threads
1,215,327
Messages
6,124,289
Members
449,149
Latest member
mwdbActuary

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