Solved How can I copy rows based on cell values in Excel?

April 20, 2013 at 14:41:02
Specs: Windows XP
 Here's an example of similar data:Name Count Column3 Column4A 2 50 51B 1 40 41C 0 1 2D 3 52 55What macro could I create that would produce this data?Name Count Column3 Column4A 2 50 51A 2 50 51B 1 40 41D 3 52 55D 3 52 55D 3 52 55Put into words, what macro could I create that would repeat each row the number of times contained in Column B?

See More: How can I copy rows based on cell values in Excel?

#1
April 20, 2013 at 18:51:15
 ```Sub CopyByNumber() 'Determine last Row with data in Column A lastRw = Range("A" & Rows.Count).End(xlUp).Row 'Loop throught rows in reverse order For srcRw = lastRw To 2 Step -1 'Determine how many rows to copy and insert copyNum = Cells(srcRw, 2) - 1 'If Column B was 0, delete the Row If copyNum = -1 Then Rows(srcRw).EntireRow.Delete End If 'If Column B was not 0, Copy and insert For copyRw = 1 To copyNum Rows(srcRw).Copy Rows(srcRw).Insert Next Next End Sub```Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.