Forum Discussion
how do i duplicate rows based on a cells value
ajames1450 I believe I understand what you are asking for. In the attached spreadsheet, I have retained your posted data (in A1:E7), but clarified the heading in C1.
Note that empty rows (in the first three columns) may appear to not cause a problem, but should be avoided. If you have too many at the wrong location, that will result in wrong calculations.
The formulas for row 2 (which should be copied down as needed):
'rows needed
=IFERROR( CEILING(C2/B2, 1), "-" )
'first row [into which to populate this product row]
=IF( A2="", "-", 2+SUM(F$1:F1) )
'Ref[ers to] Row
=IFERROR( MATCH( ROW(), G$2:G2, 1)+1, 2 )
'Product
=IF( J2=0, "-", INDIRECT("A"&H2) )
'Qty to [include in this] Ship[ment/Box/etc.]
=MIN( INDIRECT("B"&H2), IF(H2<>H1, INDIRECT("C"&H2), INDIRECT("C"&H2)-SUMIFS(J$1:J1,H$1:H1,H2) ) )
' (The third INDIRECT and the SUMIFS are calculating the
' unfilled part of the order at that row.)
Note that most of the formulas are sensitive to the data starting in row 2. Row 1 should contain only text values.
You don't say which version of Excel you are using. If you are using one of these versions, you can use the LET function to reduce the number of columns used (and write more understandable formulas): Excel for Microsoft 365; Excel for Microsoft 365 for Mac; Excel for the web; Excel 2021; Excel 2021 for Mac