Cut Smaller Pieces From Bigger Pieces

Solon Aquila

New Member
Joined
Sep 24, 2011
Messages
33
Where I work, I take large remnants of raw material and see if I can cut them down to smaller pieces so we have less waste. I've created a few spreadsheets that allow me to do this a bit more efficiently.
Once I've decided which piece to cut, the meat of the operation lies in being able to get the most pieces from the original block.
It took me a bit to work out but I have a spreadsheet that looks at all possible cutting combinations (how I did it is a separate tab).
The attached image (sorry, I can't get xl2bb to load) shows 6 source to work piece combinations.
Each uses formulas to determine the number of pieces yielded by that combination.
In case multiple combinations yield the same number of pieces, I use 'which leaves the largest individual piece of leftover' as the decider. That's not AS critical, but it gives more options for getting another part from the leftover.
I'm trying to figure out how to write a script that will look at the source piece and work piece dimensions and work out which combination gives the best yield / leftover combination.
I think I can set up variables for each dimension and use that spreadsheet as a basis for figuring out how to do the calculations.

So, if I take a look at the formulas I used in the spreadsheet, can I basically assign variables to the results of each calculation, then compare each result variable to determine which is best.
Kind of (currently ignoring largest leftover piece):
Sl= source length cell Pl= piece length cell RA=Result A RC=Result C RF=Result F
Sw=source width cell Pw= piece width cell RB=Result B RD=Result D
Sh=source height cell Ph= piece height cell RC=Result C RE=Result E
(Sl÷Pl) × (Sw÷Pw) × (Sh÷Ph)= RA
(Sl÷Ph) × (Sw÷Pl) × (Sh÷Pw)= RB
(Sl÷Pw) × (Sw÷Ph) × (Sh÷Pl)= RC
(Sl÷Pl) × (Sw÷Ph) × (Sh÷Pw)= RD
(Sl÷Pw) × (Sw÷Pl) × (Sh÷Ph)= RE
(Sl÷Ph) × (Sw÷Pw) × (Sh÷Pl)= RF

In a standard spreadsheet, I would go to the bottom of the results column and say "MAX(RA, RB, RC, RD, RE, RF, RG)" but I don't know how to do that in a script.

So, if it looks like the 'code' above appears to be a workable way to test all of the options, how the heck do I say "pick the max of these" in a script?

TIA
:-)
 

Attachments

  • 01_Cutting_1.1.jpg
    01_Cutting_1.1.jpg
    150.8 KB · Views: 47
@Solon Aquila , by Basic Excel I meant using standard Excel functions to create formulas within a workbook/worksheet, just as I assume you will have done within your posted image sheet.
More presumptive waffle......
Latest versions of Excel do indeed offer many other 'options' in the way of features for computation, analytics and automation. However, majority of users will only ever need to use a minute proportion of what Excel has to offer. Regarding 'code', I am pretty confident that you are meaning the use of VBA. VBA is the programming language associated with Macros, be they recorded or purpose-written. A well constructed Macro can certainly be a powerful option, especially when looking to automate a repetitive task. However, Macros are not necessarily a silver bullet, solving-wise, compared to using standard Excel.
Have you tested the solution I posted? If not, then test it in an otherwise empty sheet of your workbook. I'm hopeful that might be close to what you are wanting.
Click on the Copy icon at the top left corner of the XL2BB MiniSheet. Then Paste into cell A1 of the empty sheet

You can then enter Block Dimensions in C3:E3 The order of dimension does not matter.
Enter the Piece Dimensions in C4:E4. The order of dimension does not matter.

The best cutting option* should then be automatically displayed below. (Hence why might you need a macro?)
* Based solely on piece yield. Does not include a tie-breaker.

The orange cells are 'helpers' for computational purposes and may be hidden.

If the above does prove to be of value then I will happily try and help you incorporate a tie-breaker if needed.

Regarding offcuts. Volume-wise the offcuts will be the same for similar piece yield.
OffcutVol = BlockVol-(PieceVol*PieceQty)
However, the dimensions of the offcuts may vary dependent upon the relative dimensions of the cuts.

My apologies if I have anything or all of this wrong.
Snakehips,
Thank you! This is great and I finally am starting to grasp the index/match thing... well, I think I am. I've been looking at them but apparently, seeing my actual problem may have started it to gel.
There are three cells that use the match function. One of them looks like this:
=INDEX(H8:H13,MATCH(MAX($G8:$G13),$G8:$G13,0))
If I understand correctly:
INDEX in this case is kind of "we're going to choose the value in one of the cells in column H, rows 8-13" and everything after that is the 'how will we decide which one".
The MATCH portion is three fold:
First, the 'value we are trying to match' is defined in this case as 'the maximum value found in cells G8:G13' We could actually use a value, not a formula, here if we wanted (just not in this case).
Second, "figure out which of the H8:H13 cells is in the same row as the maximum value in G8:G13", though it could easily be set for a different location in a different situation. We'll be using that H8:H13 value.
Third, if we can't find an exact match between the maximum value in G8:G13 and the values in H8:H13, then return an error. There are a couple of other options, but we want an error in this situation.
The formula is repeated in columns I and J with the same actions going on, just using the values in columns I and J to match the maximum of G8:G13.
Either way, this does the trick for not having to display all results and highlighting the best one.
I'll try it out and maybe see if I can use the info you provided to play around with the max leftover size as a tie breaker.
Thank you!
 
Upvote 0

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
You are welcome, Glad to hear that it is of benefit.
Your understanding of the Index / Match is spot on. Typically using formula expressions to generate formula parameters.
Good luck with sorting the tie-breaker.
If you need any assistance with that, don't be afraid to shout up.
 
Upvote 0
My shot at tie-breaking equal piece quantity, based on maximum offcut.

Testing Formula Update.xlsm
ABCDEFGHIJKLMNO
1
2ENTER DIMENSIONSHelper Columns (Can Hide or Move Elsewhere)Helper Columns (Can Hide or Move Elsewhere)
3Block Dims >91.2567.555131083.501
4Piece Dims >6.755.59.125Combo Qtys161210Offcuts3.251.50
5Best Cutting Option107603.6250.25
6Use Block Dim 91.2567.555
7To Cut Piece Dim9.1256.755.5QTYPiece DimTieBreakOffcuts
8Cut Qty 1010109366.755.59.125 3.51.50.25
9Offcut0009106.759.1255.5 3.53.6250
10Total Pieces10009605.56.759.125 3.2500.25
1110009.1256.755.50000
128965.59.1256.75 3.253.6251
139609.1255.56.75 000
14
Sheet5
Cell Formulas
RangeFormula
H3H3=QUOTIENT(C3,C4)
I3I3=QUOTIENT(D3,C4)
J3J3=QUOTIENT(E3,C4)
H4H4=QUOTIENT(C3,D4)
I4I4=QUOTIENT(D3,D4)
J4J4=QUOTIENT(E3,D4)
H5H5=QUOTIENT(C3,E4)
I5I5=QUOTIENT(D3,E4)
J5J5=QUOTIENT(E3,E4)
L3L3=MOD(C3,C4)
M3M3=MOD(D3,C4)
N3N3=MOD(E3,C4)
L4L4=MOD(C3,D4)
M4M4=MOD(D3,D4)
N4N4=MOD(E3,D4)
L5L5=MOD(C3,E4)
M5M5=MOD(D3,E4)
N5N5=MOD(E3,E4)
C6:E6,N8D6=D3
C7:E7D7=INDEX(I8:I13,MATCH(MAX($K8:$K13),$K8:$K13,0))
C8:E8D8=QUOTIENT(D6,D7)
C9:E9D9=INDEX(M8:M13,MATCH(MAX($K8:$K13),$K8:$K13,0))
G8G8=H3*I4*J5
H8:J8H8=C4
K8:K13K8=IF(G8=MAX(G$8:G$13),MAX(L8:N8),"")
L8,N9:N10L8=L3
M8:M9M8=M4
G9G9=H3*I5*J4
H9H9=C4
I9I9=E4
J9J9=D4
L9:L11L9=L3
G10G10=(H4*I3*J5)
H10H10=D4
I10I10=C4
J10J10=E4
M10,N11,M12M10=M3
G11G11=H5*I3*J4
H11H11=E4
I11:J11I11=C4
M11,L12:L13M11=M3
G12G12=H4*I5*J3
H12:I12H12=D4
J12J12=C4
N12:N13N12=N3
G13G13=H5*J3*I4
H13H13=E4
I13I13=D4
J13J13=C4
M13M13=M3
C10C10=MAX(G8:G13)
 
Upvote 0
My shot at tie-breaking equal piece quantity, based on maximum offcut.

Testing Formula Update.xlsm
ABCDEFGHIJKLMNO
1
2ENTER DIMENSIONSHelper Columns (Can Hide or Move Elsewhere)Helper Columns (Can Hide or Move Elsewhere)
3Block Dims >91.2567.555131083.501
4Piece Dims >6.755.59.125Combo Qtys161210Offcuts3.251.50
5Best Cutting Option107603.6250.25
6Use Block Dim 91.2567.555
7To Cut Piece Dim9.1256.755.5QTYPiece DimTieBreakOffcuts
8Cut Qty 1010109366.755.59.125 3.51.50.25
9Offcut0009106.759.1255.5 3.53.6250
10Total Pieces10009605.56.759.125 3.2500.25
1110009.1256.755.50000
128965.59.1256.75 3.253.6251
139609.1255.56.75 000
14
Sheet5
Cell Formulas
RangeFormula
H3H3=QUOTIENT(C3,C4)
I3I3=QUOTIENT(D3,C4)
J3J3=QUOTIENT(E3,C4)
H4H4=QUOTIENT(C3,D4)
I4I4=QUOTIENT(D3,D4)
J4J4=QUOTIENT(E3,D4)
H5H5=QUOTIENT(C3,E4)
I5I5=QUOTIENT(D3,E4)
J5J5=QUOTIENT(E3,E4)
L3L3=MOD(C3,C4)
M3M3=MOD(D3,C4)
N3N3=MOD(E3,C4)
L4L4=MOD(C3,D4)
M4M4=MOD(D3,D4)
N4N4=MOD(E3,D4)
L5L5=MOD(C3,E4)
M5M5=MOD(D3,E4)
N5N5=MOD(E3,E4)
C6:E6,N8D6=D3
C7:E7D7=INDEX(I8:I13,MATCH(MAX($K8:$K13),$K8:$K13,0))
C8:E8D8=QUOTIENT(D6,D7)
C9:E9D9=INDEX(M8:M13,MATCH(MAX($K8:$K13),$K8:$K13,0))
G8G8=H3*I4*J5
H8:J8H8=C4
K8:K13K8=IF(G8=MAX(G$8:G$13),MAX(L8:N8),"")
L8,N9:N10L8=L3
M8:M9M8=M4
G9G9=H3*I5*J4
H9H9=C4
I9I9=E4
J9J9=D4
L9:L11L9=L3
G10G10=(H4*I3*J5)
H10H10=D4
I10I10=C4
J10J10=E4
M10,N11,M12M10=M3
G11G11=H5*I3*J4
H11H11=E4
I11:J11I11=C4
M11,L12:L13M11=M3
G12G12=H4*I5*J3
H12:I12H12=D4
J12J12=C4
N12:N13N12=N3
G13G13=H5*J3*I4
H13H13=E4
I13I13=D4
J13J13=C4
M13M13=M3
C10C10=MAX(G8:G13)
I haven't responded to this as I'm still working to comprehend it!! I will get it worked out in my mind but I wanted to make sure to thank you while I work on it.
Solon
 
Upvote 0

Forum statistics

Threads
1,224,798
Messages
6,181,038
Members
453,014
Latest member
Chris258

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