I'll try to explain my pivot table. There are a couple of phases.
First off, I somewhat recreated your table of sizes, but added an additional 'SKU' column that identifies the specific standard model. This can really be anything, but is used as the key:
From here, I created a Pivot Table (Select the table, then Organize -> Create Pivot Table -> On New Sheet).
Because Numbers makes some assumptions on how you want to summarize the data, the initial table will be junk, but a simple cleanup will take care of that.
The important thing to remember is that pivot tables work by categorizing the rows and columns from the source table. You need to provide hints as to how you want them summarized.
This is done in the Organize sidebar when looking at the Pivot Table.
This is how I set mine up:
The main considerations are:
Fields: This is the list of fields from the source table that you want to summarize (the labels are taken from the header row of the table). I have all of them selected.
You then identify the row and column parameters. For this I've added the heights (low and high) in the Columns, and the widths (low and high) in the Rows section.
One additional change here is that we don't need to total the dimensions, so for each of the first entires in the Column and Row sections, Ctrl-click the entry and select Show Field Options, then turn off the 'Show Total Columns' option:
Finally, you tell it what data to summarize. For this, I set the SKU.
Now you should have a magic table that looks something like:
Here you can see the table has summarized the various width and height combinations, marking which SKU matches. Where there isn't a match, the cell is empty, but where there is a match it identifies the SKU for the corresponding widget.
Now it's just a matter of simple(-ish)lookups. Back to the main sheet.
I created an input table where you enter the desired width and height values:
The idea here is that you enter the width and height.
For simplicity's sake I've broken it into a couple of steps to show the process, but it could be done in a single step by combining the formulas.
The important parts are:
Cell C2 = XLOOKUP($A2,SKUs::Width Low,SKUs::Width Low,"0",-1,1)
(should look like:
This performs a lookup in the SKU table using cell A2 (input width) to find the next smallest value.
A similar formula in cell D2 performs the lookup on the next smallest height value:
D2=XLOOKUP(B2,Height Low,Height Low,"0",-1,1)
This should dynamically locate the next-smallest value for each of the width and height values.
Now we can perform the lookup in the pivot table.
Cell F2= GETPIVOTDATA(SKU Pivot::$C$3,SKU Pivot::$C$3,SKU Pivot::$A$3,C2,SKU Pivot::$B$1,D2)
This takes the values in C2 and D2 and performs a lookup in the Pivot table. It will either return the SKU of the corresponding widget, or it will return 0 for no match.
Finally, I have cell E2:
E2=IF(ISTEXT(F2),"STOCK", "Custom Order")
Which checks if F2 (the PivotTable lookup) returns text or not, and sets to 'STOCK' or 'Custom Order' as appropriate. For grins, I also added conditional highlighting on this cell to show Custom Order as red text to highlight it.
Happy to send you my worksheet if recreating it from this diatribe is too much :)