Copy some information from sheet1 to sheet2
Sub CopyData()
Dim iLastRow As Long
Dim i As Long, j As Long, k As Long
With Worksheets("Sheet1")
iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range("A1:C1").Copy Destination:=Worksheets("Sheet2").Range("A1")
For i = 2 To iLastRow
For k = 1 To .Cells(i, 3).Value
j = j + 1
.Cells(i, "A").Resize(1, 3).Copy Destination:= _
Worksheets("Sheet2").Cells(j, "A")
Next k
Next i
End With
End Sub
--
HTH
RP
(remove nothere from the email address if mailing direct)
"john_liu" wrote in message
...
I have the following information on the sheet1
Products Color Quantity
Bike Blue 3
Chair Yellow 2
Table Brown 4
....
What I want is to copy above information to the sheet2 according to the
number of quantity. In above example, the sheet2 should contain the infor
as;
Products Color Quantity
Bike Blue 3
Bike Blue 3
Bike Blue 3
Chair Yellow 2
Chair Yellow 2
Table Brown 4
Table Brown 4
Table Brown 4
Table Brown 4
....
Could someone help me out. Thanks
J
|