Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Copy some information from sheet1 to sheet2

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy data from sheet2 to sheet1 when sheet2 has variable # of rows Anne Excel Discussion (Misc queries) 6 February 27th 09 09:48 PM
how do copy "sheet1!A1+1 in sheet2 to sheet 3 and get "sheet2!A1+ Dany Excel Discussion (Misc queries) 5 April 16th 07 03:27 AM
Copy result from sheet1 to sheet2 Winnie Excel Discussion (Misc queries) 3 June 26th 06 09:22 AM
Copy values from Sheet1 to Sheet2 Eintsein_mc2 Excel Discussion (Misc queries) 1 January 6th 05 05:02 AM
Copy values only, sheet1 to sheet2 without Selection Robert Christie[_3_] Excel Programming 4 October 20th 04 02:05 PM


All times are GMT +1. The time now is 02:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"