Finding which 4 boxes can hold product X's dimensions

mystic_muffin

New Member
Joined
Apr 19, 2017
Messages
17
Hey, Friends;

So lets say I have 4 box sizes with their dimension in a list. I also have an array of objects to fit in the boxes with their own dimensions. I only want to fit one item in one box so i want the box that fits the item the best. Under my "box that fits" column, I'd like a formula or something that can look down the item dimensions and compare them to the box dimensions and find whatever box works best with item, then display the name from column A. So if i have an item that 9x9x9 and a box that is 10x10x10, my sheet will choose that box because the item is just less than the box size.
box namebox lengthbox widthbox heightitem nameitem lengthitem widthitem heightbox that fits
box one100681001111906088
box two110584322221055030
box three7843353333202010
box four4843364444406090

<tbody>
</tbody>


Can anyone help me out with this?

I appreciate any assistance. Let me know if i need to clear anything up.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
For ease of visualization, I split the tables like so:

ABCDE
1box namebox lengthbox widthbox height
2box one10068100
3box two1105843
4box three784335
5box four484336
6
7
8item nameitem lengthitem widthitem heightsmallest box that fits
91111906088box one
1022221055030box two
113333202010box four
124444406090box one
135555704040box two
146666704045box one
157777707030No Match
16

<tbody>
</tbody>
Sheet8

Array Formulas
CellFormula
E9{=IFERROR(INDEX($A$2:$A$5,MOD(SMALL(IF(D9<=$D$2:$D$5,IF(MAX(B9,C9)<=$B$2:$B$5,IF(MIN(B9,C9)<=$C$2:$C$5,$B$2:$B$5*$C$2:$C$5+(ROW($A$2:$A$5)-ROW($A$2)+1)/100))),1),1)*100),"No Match")}

<tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>



I made a few assumptions. First, that on the first table, the length is always more than the width. Second, on the second table, the length and width can be in either order, and that it doesn't matter which comes first, since you can rotate the item 90 degrees. The height is pretty much required, since most products have a definite top/bottom. And for smallest box, I chose the box with the smallest square inches for the base, that both length and width dimensions fit, and the height fits.

Given that, the array formula in E9 should get you what you want. Let me know what you think.
 
Last edited:
Upvote 0
For ease of visualization, I split the tables like so:

ABCDE
1box namebox lengthbox widthbox height
2box one10068100
3box two1105843
4box three784335
5box four484336
6
7
8item nameitem lengthitem widthitem heightsmallest box that fits
91111906088box one
1022221055030box two
113333202010box four
124444406090box one
135555704040box two
146666704045box one
157777707030No Match
16

<tbody>
</tbody>
Sheet8

Array Formulas
CellFormula
E9{=IFERROR(INDEX($A$2:$A$5,MOD(SMALL(IF(D9<=$D$2:$D$5,IF(MAX(B9,C9)<=$B$2:$B$5,IF(MIN(B9,C9)<=$C$2:$C$5,$B$2:$B$5*$C$2:$C$5+(ROW($A$2:$A$5)-ROW($A$2)+1)/100))),1),1)*100),"No Match")}

<tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>



I made a few assumptions. First, that on the first table, the length is always more than the width. Second, on the second table, the length and width can be in either order, and that it doesn't matter which comes first, since you can rotate the item 90 degrees. The height is pretty much required, since most products have a definite top/bottom. And for smallest box, I chose the box with the smallest square inches for the base, that both length and width dimensions fit, and the height fits.

Given that, the array formula in E9 should get you what you want. Let me know what you think.

Works wonderfully! This is exactly what I was looking for. Thank so much, i really appreciate it. Now I need to fiddle around with it so i can learn how this thing works!
 
Upvote 0
If the sizes of the boxes are in descending order, maybe this formula also works (using data sample provided by Eric in post #2 )

Formula in E9 copied down
=IFERROR(LOOKUP(2,1/(MMULT(--($B$2:$D$5-B9:D9>0),{1;1;1})=3),$A$2:$A$5),"No Match")
confirmed with just Enter

M.
 
Last edited:
Upvote 0
Let me know what you think.

Now that I've goofed around with this some, one thing:

If I paint this formula down a column where there is no dimension info in a row yet, it assumes the dimensions are '0' and it assumes it will fit in the smallest box.

Is there any way that we can stop the formula from calculating if there is a '0'?

Or is there a more eloquent way of doing this?

I appreciate the help!
 
Upvote 0
It's easy enough to add a check to see if there's an Item Name before calculating:

ABCDEFG
1box namebox lengthbox widthbox height
2Box one10068100
3Box two1105843
4Box three784335
5Box Four484336
6
7
8Item nameitem lengthitem widthItem heightSmallest box that fits
91111906088Box oneBox one
1022221055030Box twoBox two
113333202010Box FourBox Four
124444406090Box oneBox one
135555704040Box twoBox two
146666704045Box oneBox one
157777707030No MatchNo Match
1688885010530Box twoNo Match
17

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet11

Worksheet Formulas
CellFormula
G9=IF(A9="","",IFERROR(LOOKUP(2,1/(MMULT(--($B$2:$D$5-B9:D9>0),{1;1;1})=3),$A$2:$A$5),"No Match"))

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>

Array Formulas
CellFormula
E9{=IF(A9="","",IFERROR(INDEX($A$2:$A$5,MOD(SMALL(IF(D9<=$D$2:$D$5,IF(MAX(B9,C9)<=$B$2:$B$5,IF(MIN(B9,C9)<=$C$2:$C$5,$B$2:$B$5*$C$2:$C$5+(ROW($A$2:$A$5)-ROW($A$2)+1)/100))),1),1)*100),"No Match"))}

<thead>
</thead><tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>



I added Marcelo's formula as well, with the same change. His seems to work just as well, and is shorter, although I haven't tested it extensively. The one difference is that his requires you to enter the largest dimension first in the second table, to match the first table, as well as having table 1 in descending box size. Items 2222 and 8888 are the same with just the height and width reversed.
 
Upvote 0
My formula above needs a small adjustment
=IFERROR(LOOKUP(2,1/(MMULT(--($B$2:$D$5-B9:D9>=0),{1;1;1})=3),$A$2:$A$5),"No Match")

M.
 
Upvote 0
Hi all,

It's easy enough to add a check to see if there's an Item Name before calculating:

ABCDEFG
1box namebox lengthbox widthbox height
2Box one10068100
3Box two1105843
4Box three784335
5Box Four484336
6
7
8Item nameitem lengthitem widthItem heightSmallest box that fits
91111906088Box oneBox one
1022221055030Box twoBox two
113333202010Box FourBox Four
124444406090Box oneBox one
135555704040Box twoBox two
146666704045Box oneBox one
157777707030No MatchNo Match
1688885010530Box twoNo Match
17

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet11

Worksheet Formulas
CellFormula
G9=IF(A9="","",IFERROR(LOOKUP(2,1/(MMULT(--($B$2:$D$5-B9:D9>0),{1;1;1})=3),$A$2:$A$5),"No Match"))

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>

Array Formulas
CellFormula
E9{=IF(A9="","",IFERROR(INDEX($A$2:$A$5,MOD(SMALL(IF(D9<=$D$2:$D$5,IF(MAX(B9,C9)<=$B$2:$B$5,IF(MIN(B9,C9)<=$C$2:$C$5,$B$2:$B$5*$C$2:$C$5+(ROW($A$2:$A$5)-ROW($A$2)+1)/100))),1),1)*100),"No Match"))}

<thead>
</thead><tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>



I added Marcelo's formula as well, with the same change. His seems to work just as well, and is shorter, although I haven't tested it extensively. The one difference is that his requires you to enter the largest dimension first in the second table, to match the first table, as well as having table 1 in descending box size. Items 2222 and 8888 are the same with just the height and width reversed.

the formula described above works great to solve the initial problem.

I would also like to consider not only turning the product 90 degrees to change length and width, but also turning the height dimension. Is there a way to modify the formula so that you can test if the product fits in the box by trying to rotate it in all dimensions? @Eric W

Thanks for your help
 
Upvote 0
Probably the easiest way is to use this variation of Marcelo's formula:

Book1 (version 1).xlsb
ABCDEFGHIJKL
1Box NameDimension1Dimension2Dimension3Volumeitem nameitem lengthitem widthitem heightsmallest box that fits
2Box One681001006800001111906088Box One
3Box Two435811027434022221055030Box Two
4Box Three3543781173903333202010Box Six
5Box Four364348743044444406090Box One
6Box Five253040300005555704040Box Two
7Box Six202560300006666704045Box Two
87777707030Box One
9888870100110No Match
Sheet6
Cell Formulas
RangeFormula
E2:E7E2=PRODUCT(B2:D2)
L2:L9L2=IFERROR(LOOKUP(2,1/(MMULT(--(SMALL(I2:K2,{1,2,3})<=$B$2:$D$7),{1;1;1})=3),$A$2:$A$7),"No Match")


To make this work right, the dimensions of the boxes in the A1:E7 table must be in order, smallest dimension on the left, largest on the right, then sort the rows of the tables in decreasing volume size. The dimensions in the H1:L9 table do not need to be entered in size order.
 
Upvote 0
Probably the easiest way is to use this variation of Marcelo's formula:

Book1 (version 1).xlsb
ABCDEFGHIJKL
1Box NameDimension1Dimension2Dimension3Volumeitem nameitem lengthitem widthitem heightsmallest box that fits
2Box One681001006800001111906088Box One
3Box Two435811027434022221055030Box Two
4Box Three3543781173903333202010Box Six
5Box Four364348743044444406090Box One
6Box Five253040300005555704040Box Two
7Box Six202560300006666704045Box Two
87777707030Box One
9888870100110No Match
Sheet6
Cell Formulas
RangeFormula
E2:E7E2=PRODUCT(B2:D2)
L2:L9L2=IFERROR(LOOKUP(2,1/(MMULT(--(SMALL(I2:K2,{1,2,3})<=$B$2:$D$7),{1;1;1})=3),$A$2:$A$7),"No Match")


To make this work right, the dimensions of the boxes in the A1:E7 table must be in order, smallest dimension on the left, largest on the right, then sort the rows of the tables in decreasing volume size. The dimensions in the H1:L9 table do not need to be entered in size order.
Thank you very much for your idea @Eric W.

It seems to work in your example. When I try to use your example, I unfortunately get an error. As you can see in the picture "test2", the array function leads to #N/A. I suppose it is based on the number of rows vs. columns. Is that correct? How did you solve this problem?

I am looking forward to your feedback. Thanks for your support.
 

Attachments

  • Test1.PNG
    Test1.PNG
    38.4 KB · Views: 58
  • Test2.PNG
    Test2.PNG
    43.1 KB · Views: 57
Upvote 0

Forum statistics

Threads
1,214,929
Messages
6,122,315
Members
449,081
Latest member
tanurai

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