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.
 
Would there be any significant difference to stability or speed in the spreadsheet because if XMATCH works, that's good enough for me.
It just seemed logical to me to use a single function. Given the other points you have made I don't see any particular reason to change from XMATCH. :)
 
Upvote 0

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Why not use XLOOKUP then? That will do the XMATCH and the INDEX all in one.
Book1
ABCDEFGHIJKLMNOP
3typewidthheightresult
4Holland18101200#N/A
51
6
7
8WIDTH6408401040124014401640184021402440259027402890304031903400
9DROP
1010008799105115125138149163182190199207214255297
11120096104115126135149161183201209216226236280325
121400102110125135147159173194212223233242249291332
131600106123132144155166185208229241250258266309too big
141800115130140153166184194227253269286293298339too big
152000125139152165177193210275295305317328338383too big
162200132147160175191208236288315328339348359403too big
172400142158172189204219249304329342355369382432too big
182700153169184200216240267325361376391403414460too big
193000163183199211233254286340387405421431440484too big
203300170198212223251269304357414434451458465508too big
213600178211226234268285323373441463482487491531too big
Sheet1
Cell Formulas
RangeFormula
F4F4=XLOOKUP(A4&A5&"prices",B4&A5&"height",E4&A5&"width",,1)

Peter this is what I would roughly need to work. Holland has to have the 1 after it. There are more than 1 holland price grids. The named ranges are holland1height, holland1width and holland1prices. what needs to change to make it get a result
 
Upvote 0
just noticed I have width and height in wrong places but anyway still stumped
 
Upvote 0
You are still going to need INDIRECT if you have multiple ranges that might need to be referenced.
I don't have the named ranges etc to actually test.
 
Upvote 0
You are still going to need INDIRECT if you have multiple ranges that might need to be referenced.
I don't have the named ranges etc to actually test.
see post 12 for named ranges. didn't they used to get specified in XL2BB?
 
Upvote 0
In regards to replacing XMATCH with XLOOKUP I came up with this but don't know if its any better. Named ranges are A2:A16 = vertical1height, B1:S1=vertical1width and B2:S16 = vertical1prices. please ignore the yellow cell fill.

Book1
ABCDEFGHIJKLMNOPQRS
17169461177140716371867209723272557278730183248345036783906413443614589
29007790102114130143156170183193205220235246261274286299
310507992105120135147162176187201214230241256271284299313
412008095107124137151168183196205223239253268282296313325
513508296112127143156174187202214231246262277293308323337
615008398114130147162182195208223239256271286302319335350
716508499119134151164184201214231246263282297314330347365
8180085102121137154171191205223238256274289308325340359374
9195090103126141160176198212230245263283299317335354371388
10210092106129146163183202218238253272290312329346366384401
11225094107132148165185205227244261281299317337356374396413
12240095112135151171193211233250269288308329347366388404425
13255096114137154176198218239256277296317337358376399420434
14270098119141159182202227244263283305327347367388411433450
15285099120146162184205230250271290313335358376399421443466
163000101121148164187209236256278297319345366388410434453478
17
18
19widthheightprice
20vertical120001489182
Sheet1
Cell Formulas
RangeFormula
F20F20=XLOOKUP(C20,INDIRECT(A20&B20&"WIDTH"),XLOOKUP(D20,INDIRECT(A20&B20&"HEIGHT"),INDIRECT(A20&B20&"PRICES"),,1),,1)
 
Upvote 0
In regards to replacing XMATCH with XLOOKUP I came up with this but don't know if its any better.
Sorry, I didn't have a good grasp of your data structures and named ranges before. Getting a better idea now and agree that your original INDEX/XMATCH/XMATCH idea would probably be the simplest way to go.

keithmct.xlsm
ABCDEFGHIJKLMNOPQRS
17169461177140716371867209723272557278730183248345036783906413443614589
29007790102114130143156170183193205220235246261274286299
310507992105120135147162176187201214230241256271284299313
412008095107124137151168183196205223239253268282296313325
513508296112127143156174187202214231246262277293308323337
615008398114130147162182195208223239256271286302319335350
716508499119134151164184201214231246263282297314330347365
8180085102121137154171191205223238256274289308325340359374
9195090103126141160176198212230245263283299317335354371388
10210092106129146163183202218238253272290312329346366384401
11225094107132148165185205227244261281299317337356374396413
12240095112135151171193211233250269288308329347366388404425
13255096114137154176198218239256277296317337358376399420434
14270098119141159182202227244263283305327347367388411433450
15285099120146162184205230250271290313335358376399421443466
163000101121148164187209236256278297319345366388410434453478
17
18
19widthheightprice
20vertical120001489182
Sheet1
Cell Formulas
RangeFormula
F20F20=LET(p,A20&B20,INDEX(INDIRECT(p&"prices"),XMATCH(D20,INDIRECT(p&"height"),1),XMATCH(C20,INDIRECT(p&"width"),1)))



see post 12 for named ranges. didn't they used to get specified in XL2BB?
They still do - IF the named ranges are used DIRECTLY in the formulas. Of course here they are used INDIRECTLY in the formulas so don't show. :)
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,287
Members
452,631
Latest member
a_potato

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