ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copying and Pasting Using Row Counts (https://www.excelbanter.com/excel-programming/366089-copying-pasting-using-row-counts.html)

Stubbsy.

Copying and Pasting Using Row Counts
 
I have 2 lists A and B. List A has 50 items and List B has 100 items. Each
list has 3 columns of data.

I need to copy the first line of data from List A and paste into into a new
worksheet 100 times (the length of List B) and then copy List B and paste it
next to it to create a List C.

I then need to copy the second line of data from List A and paste it below
List C again 100 times (the lenght of List B) and again, copy List B and
paste it next to it (thus creatiing a List C that is now 200 rows).

And repeat this 50 times (the number of rows of data in List A).

I understand macros, and I know I can use a Loop using ROWS(), but can't get
it quite right. Please Help !!!

Ingolf

Copying and Pasting Using Row Counts
 
Hi, Stubbsy

list A in sheet 1, list B in sheet 2 and list C in sheet 3, with a
blank sheet 3 already existing:

Dim lng As Long
For lng = 1 To 50
With ThisWorkbook
.Sheets(1).Range(.Sheets(1).Cells(lng, 1), .Sheets(1).Cells(lng,
3)) _
.Copy Destination:=.Sheets(3).Range(.Sheets(3) _
.Cells(lng * 100 - 99, 1), .Sheets(3).Cells(lng * 100, 3))
.Sheets(2).Range(.Sheets(2).Cells(1, 1), .Sheets(2).Cells(100,
3)) _
.Copy Destination:=.Sheets(3).Range(.Sheets(3) _
.Cells(lng * 100 - 99, 4), .Sheets(3).Cells(lng * 100, 6))
End With
Next 'lng

Regards
Ingolf


Stubbsy. schrieb:

I have 2 lists A and B. List A has 50 items and List B has 100 items. Each
list has 3 columns of data.

I need to copy the first line of data from List A and paste into into a new
worksheet 100 times (the length of List B) and then copy List B and paste it
next to it to create a List C.

I then need to copy the second line of data from List A and paste it below
List C again 100 times (the lenght of List B) and again, copy List B and
paste it next to it (thus creatiing a List C that is now 200 rows).

And repeat this 50 times (the number of rows of data in List A).

I understand macros, and I know I can use a Loop using ROWS(), but can't get
it quite right. Please Help !!!



Mike Fogleman

Copying and Pasting Using Row Counts
 
I may be able to help you with this, but I need to know a few things about
your data. Where are lists A & B located? Are they both on sheet1? What
range do they occupy? Are there headers? Are the lists always going to be 50
& 100 rows long or can they vary in length? Does the "new worksheet" already
exist or do you want it added if it does not exist? If there are headers do
want them copied to the first row only of the "new worksheet"?
Mike F
"Stubbsy." wrote in message
...
I have 2 lists A and B. List A has 50 items and List B has 100 items. Each
list has 3 columns of data.

I need to copy the first line of data from List A and paste into into a
new
worksheet 100 times (the length of List B) and then copy List B and paste
it
next to it to create a List C.

I then need to copy the second line of data from List A and paste it below
List C again 100 times (the lenght of List B) and again, copy List B and
paste it next to it (thus creatiing a List C that is now 200 rows).

And repeat this 50 times (the number of rows of data in List A).

I understand macros, and I know I can use a Loop using ROWS(), but can't
get
it quite right. Please Help !!!





All times are GMT +1. The time now is 02:01 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com