Repeat row x times

Closed
Richard - Feb 22, 2017 at 02:57 PM
vcoolio Posts 1404 Registration date Thursday July 24, 2014 Status Moderator Last seen September 15, 2023 - Mar 1, 2017 at 03:55 AM
Hello,

I want to make some labels for products. i have a sheet with info in columns A-F(name, sku, size, description, date, and quantity.
Column F contains quantities. I need to make a sheet that repeats each row x times with x = the number in F column. Below is an example of a row. Keep in mind i have about 1000 rows like this.

ALIVIA | 1148 | S | BLOUSE | 1/1/2016 | 4


Thank you so much for your time and effort,

8 responses

vcoolio Posts 1404 Registration date Thursday July 24, 2014 Status Moderator Last seen September 15, 2023 259
Feb 23, 2017 at 02:54 AM
Hello Richard,

Perhaps the following code, assigned to a button, may do the task for you:-


Sub CopyRows()

    Dim r As Range

For Each r In Range("F2", Range("F" & Rows.Count).End(xlUp))
   Sheet2.Cells(Rows.Count, 1).End(xlUp)(2).Resize(r.Value, 5) = r.Offset(, -5).Resize(1, 5).Value
     Next r
     
End Sub


I've prepared a little sample at the following link for you to play with:-

https://www.dropbox.com/s/edpbkfor4j9vlay/Copy%20x%20number%20of%20rows%20to%20sht%202.xlsm?dl=0

Click on the "RUN" button to see it work.

I hope that this helps.

Cheerio,
vcoolio.
0