container filler or truck load pallets

cmeredith1973

New Member
Joined
Apr 8, 2019
Messages
33
Office Version
  1. 365
Platform
  1. Windows
Hi - I have a group of products and looking for a better way to identify, how many products could fit in a 53" tractor trailer.

model
product a 114, can fit in a truck, 19 skids, 6 products per skid
productb 108 can fit on a truck, 36 skids, 1 product per skid
productc 54 can fit in a truck, 18 skids, 1 per skid
product d 78 can fit in a truck, 39 skids, 1 per skid
producte 156 can fit in a truck, 38 skids, 4 per skid

I saw some success with the solver function, but cant my head around the set up. I thought to ask if others have had luck. thank you in advance.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Meredith
i hope i understood and translated your model good to the settings in range A1:G5.
For example prodA 114 = 19*6, but the others ???

Then suppose you want to ship 100 units of every product.
The (probably) best solution is to load a truck as good as possible with a combination of skids.
I hoped that i could combine skids in % of the use of a truck, row 5,
so the product of number of skids (=C12:G12) * % (=C5:M5) = M12 had to be less then 100% and is the value to be maximazid.
Then you check how many such trucks can be filled in B12.
The number of products shipped with this combination and number of trucks is in H12:L12.
Now, the question is whether you do the next step manually or with a macro (i prefer the last)
You copy the found solution B12:M12 as a new row into the table below.
This results in a saldo of remaining products in C9:G9.
Now you have to run the solver and copy that line until all products are shipped.

in B6, the number of trucks was 5.6 and after execution the number is 6 (B14) and the content is in C16:G21.
Is everything still understandable ?

VBA Code:
Sub Solve_Meredith()
     With Range("Tabel1[truck]").ListObject                     'listobject for the solutions
          If .ListRows.Count Then .DataBodyRange.Delete         'delete previous solutions

          Do                                                    'in a loop
               ptr = ptr + 1                                    'increment number of loops
               SolverSolve True                                 'run solver
               MsgBox "1"                                       'just tempory a msgbox after very run to see the result,
               bflag = (Range("My_Truck").Value < 100)          'check if number of trucks>100, then terminate
               If bflag Then
                    Set c = Range("B12:M12")                    'range with the values
                    With .ListRows.Add.Range.Range("A1")        'add a new listrow
                         .Value = "Combination " & ptr          'combination number in A
                         .Offset(, 1).Resize(, c.Columns.Count).Value = c.Value     'all the other values
                    End With
               End If
          Loop While bflag And ptr < 20                         'determine if you have to search further
     End With
End Sub

opl.xlsb
ABCDEFGHIJKLM
1productABCDE
2#1141085478152
3skids/truck1936183938
4products/skid63324
5truck/skid5,26%2,78%5,56%2,56%2,63%
6estimate5,60,90,91,91,30,7
7
8My QTY100100100100100
9saldo00000
10skids00000
11# trucksskids ASkids BSkids CSkids DSkids EABCDE
12My Truck100000000000000000000,0%
13
14Totaal6100100100100100
15trucktrucksskids ASkids BSkids CSkids DSkids EABCDE% load
16Combination 11001800005400100,0%
17Combination 21201600120460099,4%
18Combination 31157000882100098,4%
19Combination 41027009079003698,7%
20Combination 510002216000446498,5%
21Combination 6100028000056071,8%
Blad1
Cell Formulas
RangeFormula
C5:G5C5=1/C3
B6B6=SUM(C6:G6)
C6:G6C6=+C8/(C3*C4)
C9:G9C9=+C8-INDEX($A$14:$L$14,MATCH(C1,Tabel1[#Headers],0))
C10:G10C10=+CEILING.MATH(C9/C4,1)
B12B12=TRUNC(MIN(IF(C12:G12>0,TRUNC(C10:G10/C12:G12),1000000000)))
H12:L12H12=MIN(C9,C12*C4*$B$12)
M12M12=SUMPRODUCT(C12:G12,C5:G5)
B14B14=SUBTOTAL(109,Tabel1[trucks])
H14H14=SUBTOTAL(109,Tabel1[A])
I14I14=SUBTOTAL(109,Tabel1[B])
J14J14=SUBTOTAL(109,Tabel1[C])
K14K14=SUBTOTAL(109,Tabel1[D])
L14L14=SUBTOTAL(109,Tabel1[E])
Named Ranges
NameRefers ToCells
My_Truck=Blad1!$B$12H12:L12
solver_adj=Blad1!$C$12:$G$12M12, B12, H12
solver_lhs1=Blad1!$C$12:$G$12M12, B12, H12
solver_lhs2=Blad1!$C$12:$G$12M12, B12, H12
solver_rhs0=Blad1!$C$9:$G$9H12, C10
solver_rhs1=Blad1!$C$10:$G$10B12
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C8:G8Expression=C8<>H14textNO
A16:L21Expression=A16=0textNO
 
Upvote 0
hey this looks like something that I could really get behind, thank you so very much for your time to lay this out. I'll get back to you once I get it into an excel and work some of the details.
 
Upvote 0
you're welcome.
I added a link in the beginning of #2
 
Upvote 0
This is amazing, I dont quite yet understand how to make it work, but I am deeply grateful for your time and positive energy. I prefer a macro too. I copy B12:m12, as a new row, or in the example row 22, but then I lost the plot of what you did. when I copied into row 22, I had an error message and the solver said it was an error value in the objective cell or a constraint cell.

What happens, if the order quantity isn't 100. I could have a mixed order, of 10 of Product A, 12 of product b, etc. What I have is customers who will order a mix bag of product and im trying to get it into a truck estimator.,
 
Upvote 0
manually version
1. you have to empty (=delete all listrows) of the table in A15.
2. you change the wanted quantities in C8:G8
3. you run the solver
4. you copy B12:M12 as a new row in the table (go to the B-cell of the next free line and paste there + add comment in the A-cell)
5. repeat 3&4 until line 9 contains only zeros

macro version
(0. make sure that the "solver"-reference is choosen in your references in VBA, Extra>References)
1. you change the wanted quantities in C8:G8
2. run the macro
 

Attachments

  • Schermafbeelding 2022-02-25 092731.png
    Schermafbeelding 2022-02-25 092731.png
    26.3 KB · Views: 12
Upvote 0
same link as yesterday Meredith
with an extra macro to fill random numbers in C8;G8.
a small problem, i don't know why the conditional format in row 9 isn't working correct, only the non-zeros have to become orange.
It's always those products used in the last combination that remain orange, even when their value is zero.
opl.xlsb
ABCDEFGHIJKLM
1productABCDE
2#1141085478152
3skids/truck1936183938
4products/skid63324
5truck/skid5,26%2,78%5,56%2,56%2,63%
6estimate2,10,50,70,40,30,1
7
8My QTY5878242714
9saldo00000
10skids00000
11# trucksskids ASkids BSkids CSkids DSkids EABCDE
12My Truck100000000000000000000,0%
13
14Totaal35878242714
15trucktrucksskids ASkids BSkids CSkids DSkids EABCDE% load
16Combination 11101800583240099,9%
17Combination 2102201140660221499,8%
18Combination 31030300905016,0%
Blad1
Cell Formulas
RangeFormula
C5:G5C5=1/C3
B6B6=SUM(C6:G6)
C6:G6C6=+C8/(C3*C4)
C9:G9C9=+C8-INDEX($A$14:$L$14,MATCH(C1,Tabel1[#Headers],0))
C10:G10C10=+CEILING.MATH(C9/C4,1)
B12B12=TRUNC(MIN(IF(C12:G12>0,TRUNC(C10:G10/C12:G12),1000000000)))
H12:L12H12=MIN(C9,C12*C4*$B$12)
M12M12=SUMPRODUCT(C12:G12,C5:G5)
B14B14=SUBTOTAL(109,Tabel1[trucks])
H14H14=SUBTOTAL(109,Tabel1[A])
I14I14=SUBTOTAL(109,Tabel1[B])
J14J14=SUBTOTAL(109,Tabel1[C])
K14K14=SUBTOTAL(109,Tabel1[D])
L14L14=SUBTOTAL(109,Tabel1[E])
Named Ranges
NameRefers ToCells
My_Truck=Blad1!$B$12H12:L12
solver_adj=Blad1!$C$12:$G$12M12, B12, H12
solver_lhs1=Blad1!$C$12:$G$12M12, B12, H12
solver_lhs2=Blad1!$C$12:$G$12M12, B12, H12
solver_rhs0=Blad1!$C$9:$G$9H12, C10
solver_rhs1=Blad1!$C$10:$G$10B12
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C9:G9Expression=GEHEEL(C9)<>0textNO
A16:L18Expression=A16=0textNO
 
Upvote 0
Solution
Wow! This really helpful and thank you for the buttons. If I wanted to add products, just keep pushing everything to the right? Thank you for this.
 
Upvote 0

Forum statistics

Threads
1,214,374
Messages
6,119,162
Members
448,870
Latest member
max_pedreira

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