getting next largest price from grid if no exact match found

keithmct

Active Member
Joined
Mar 9, 2007
Messages
256
Office Version
  1. 2021
Platform
  1. Windows
I need a reminder folks. I've been using index match for a long time on my price grids and have to re-arrange the grids (from suppliers) from left to right and top to bottom as highest value first and have a "-1" in there so that when exact price isn't found it grabs the next highest price when using my formula:
=IF(I15<>"",INDEX(INDIRECT(E15&AE15&"prices"),MATCH(I15,INDIRECT(E15&AE15&"height"),-1),MATCH(G15,INDIRECT(E15&AE15&"width"),-1)),"0")
But didn't I see somewhere that there had been a change so that you could put something in place of the "-1" and I wouldn't have to muck around with flipping price grids?
There shouldn't be a need to explain the cell references in the above, I just need to know about the possible general INDEX/MATCH improvement.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
If your values are sorted in descending order, you can add the -1 switch to the MATCH function ( inside the function itself)

Match_typeBehavior
1 or omittedMATCH finds the largest value that is less than or equal to lookup_value. The values in the lookup_array argument must be placed in ascending order, for example: ...-2, -1, 0, 1, 2, ..., A-Z, FALSE, TRUE.
0MATCH finds the first value that is exactly equal to lookup_value. The values in the lookup_array argument can be in any order.
-1MATCH finds the smallest value that is greater than or equal tolookup_value. The values in the lookup_array argument must be placed in descending order, for example: TRUE, FALSE, Z-A, ...2, 1, 0, -1, -2, ..., and so on.
 
Upvote 0
Nothing has changed in the Match function, however in 2021 & 365 there is the Xmatch function which does not need sorted data.
 
Upvote 0
Solution
Nothing has changed in the Match function, however in 2021 & 365 there is the Xmatch function which does not need sorted data.
Ah, that's it. However, I found this:
"What is the significance of the 1 in the function Xmatch?
Understanding the XMATCH Function in Excel
A match type of -1 means that the position within the array of the first entry less than or equal to the lookup value is returned and a match type of 1 means that the position within the array of the first entry more than the lookup value is returned."

I would like a 1 to mean more than or equal to the lookup value. I this just a misprint or will I always get the next highest value even when there is an exact match?
 
Upvote 0
when exact price isn't found it grabs the next highest price
Ignoring all your INDIRECT issues, does this INDEX/MATCH/AGGREGATE combination do what you want?

23 11 16.xlsm
ABCDEF
1ItemPricePriceItem
2A25F
3D82.1Y
4F5
5Y3
Lookup
Cell Formulas
RangeFormula
F2:F3F2=INDEX(A$2:A$5,MATCH(AGGREGATE(15,6,B$2:B$5/(B$2:B$5>=E2),1),B$2:B$5,0))
 
Upvote 0
l also found this on exceljet which seems to answer (if you can trust it) whether "1" does what I want:

However, for approximate matches, the behavior is different when match_type is set to 1:

=MATCH(value,array,1) // exact match or next smallest
=XMATCH(value,array,1) // exact match or next *largest*
 
Upvote 0
seems to answer (if you can trust it) whether "1" does what I want:
For MATCH at least, I think that you need to read further down that page ..

1700111081397.png



Also, if you are considering using XMATCH, does your forum profile need updating?
According to Microsoft Help on XMATCH it is not available in Excel 2019 as shown in your profile.
 
Last edited:
Upvote 0
For MATCH at least, I think that you need to read further down that page ..

View attachment 102013


Also, if you are considering using XMATCH, does your forum profile need updating?
According to Microsoft Help on XMATCH it is not available in Excel 2019 as shown in your profile.
Profile now updated. I'm going to go with XMATCH as it should find the exact value or the next highest value, as opposed to the statement from post #4 (I can't find where I sourced that now).
 
Upvote 0
Cheers. (y)

Why not use XLOOKUP then? That will do the XMATCH and the INDEX all in one.
Would there be any significant difference to stability or speed in the spreadsheet because if XMATCH works, that's good enough for me. Not sure if it matters but my 67 different shaped/sized price grids with named ranges for each height, width and price array make it less than exciting to jump in and change everything now. I don't even work for that company now. I'm just trying to make it easy for the owner.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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