Copy row by x times where value x is cell value of the range [Solved]

Ask a question davidang 1Posts Thursday February 16, 2017Registration date February 16, 2017 Last seen - Last answered on Feb 21, 2017 at 11:59 AM by TrowaD
I need to scan each value in a column A and use the value in that column to copy the current row x times to another sheet. The second sheet is to be used as a source document for labels mail merge
plus moins
Hi Davidang,

The following code will work when you call your source sheet "Sheet1" and your destination sheet "Sheet2" or find and change those references in the code.

Here is the code:
Sub RunMe()
Dim x As Integer


For Each cell In Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row)
    x = cell.Value
    Do Until x = 0
        Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial
        x = x - 1
Next cell

Application.CutCopyMode = False

End Sub

Best regards,
daveang70 1Posts Thursday February 16, 2017Registration date February 21, 2017 Last seen - Feb 21, 2017 at 11:39 AM
Hi Trowa

I tested it. Yes it works and fulfill my requirement. Thanks a million.

TrowaD 2282Posts Sunday September 12, 2010Registration date ModeratorStatus October 19, 2017 Last seen - Feb 21, 2017 at 11:59 AM
Leave a comment

Member requests are more likely to be responded to.

Members can monitor the statuses of their requests from their account pages.

A CCM membership gives you access to additional options.

Not a member yet?

Sign up now. It takes less than a minute and is completely free!