(Solved) – Copy rows multiple times (given in a cell)


I have a table containing data (ProductName, ProductId)

Excel Table

enter image description here

I would like to create a new dataset on the same sheet. The macro would copy data from the table and and it would Insert rows on column D X times. The data should look this way if X is 4:

Desired Output

enter image description here

Here’s a snippet of my code:

Sub Practice_Loop()
Dim Product As Long, i As Long, j As Long

Country = Range("A2:A10").End(xlUp).Row
For i = Product To 12
    For j = 1 To Range("A" & i).Offset(, 2).Value
       LRow2 = Range("N14" & Rows.Count).End(xlUp).Offset(1).Row
        Range("M14").Value = Range("A2" & i).Value
        Range("N11" & "LRow2").Value = Range("N2:N13" & i).Value & j
    Next j
Next i
End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *