Create multiple rows
Sub insert_Rows()
Dim rng As Range, i As Integer, cnt As Integer
Set rng = Cells(Rows.Count, 1).End(xlUp)
For i = rng.Row To 2 Step -1
' Change 2 to 1 if you don't have a header row
cnt = Cells(i, "F").Value
' this is the column with your label count change F to suit
If cnt < 1 Then
Cells(i, 1).EntireRow.Offset(1, 0).Resize(cnt - 1).Insert
Cells(i, 1).EntireRow.Copy Destination:= _
Cells(i, 1).EntireRow.Offset(1, 0).Resize(cnt - 1)
Else
End If
Next
End Sub
On May 1, 11:56 am, T. Neil wrote:
Hi--
Is there a simple way of duplicating a row multiple times based on a value?
For example, I want to create labels in word based on the number of packages
a customer has purchased. Word needs a separate record for each label
produced.
If i have the customer info in a row with the number of labels needed in the
final cell, is there a way of writing a macro to duplicate (either in the
same worksheet or a new one) that would create multiple rows based on the
value in the last cell?
Any advice would be appreciated!
|