PC Review


Reply
Thread Tools Rate Thread

Copy once and paste five times

 
 
Zuzeppeddu
Guest
Posts: n/a
 
      3rd Sep 2007
Hi

I have a column of 172 text values in Sheet2. I want to paste each
value five times in the first column of Sheet1. For example:

--------------
Sheet2:

Column A

Biscuits
Jam
Peanut
Chocolate
....


--------------
Sheet1:

Column B

Biscuits
Biscuits
Biscuits
Biscuits
Biscuits
Jam
Jam
Jam
Jam
Jam
Peanut
Peanut
Peanut
Peanut
Peanut
Chocolate
Chocolate
Chocolate
Chocolate
Chocolate
....

So far I have coded the following:

Sub Macro1()

Dim i
Dim j

For i = 1 To Sheet2.UsedRange.Rows.Count

For j = 1 To 5

Sheets(1).Range("A" & j) = Sheets(2).Range("A" &
i).Value

Next

Next


End Sub

As you can see, the above would simply paste the values over and over
again on the first five cells. I am not sure how to get around this
problem.

I would be grateful for any help.

Regards
Yousaf

 
Reply With Quote
 
 
 
 
Zone
Guest
Posts: n/a
 
      3rd Sep 2007
Sheets(1).Range("A" & (j + (i - 1) * 5)) = Sheets(2).Range("A" & i).Value
This is all on one line, of course

"Zuzeppeddu" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi
>
> I have a column of 172 text values in Sheet2. I want to paste each
> value five times in the first column of Sheet1. For example:
>
> --------------
> Sheet2:
>
> Column A
>
> Biscuits
> Jam
> Peanut
> Chocolate
> ...
>
>
> --------------
> Sheet1:
>
> Column B
>
> Biscuits
> Biscuits
> Biscuits
> Biscuits
> Biscuits
> Jam
> Jam
> Jam
> Jam
> Jam
> Peanut
> Peanut
> Peanut
> Peanut
> Peanut
> Chocolate
> Chocolate
> Chocolate
> Chocolate
> Chocolate
> ...
>
> So far I have coded the following:
>
> Sub Macro1()
>
> Dim i
> Dim j
>
> For i = 1 To Sheet2.UsedRange.Rows.Count
>
> For j = 1 To 5
>
> Sheets(1).Range("A" & j) = Sheets(2).Range("A" &
> i).Value
>
> Next
>
> Next
>
>
> End Sub
>
> As you can see, the above would simply paste the values over and over
> again on the first five cells. I am not sure how to get around this
> problem.
>
> I would be grateful for any help.
>
> Regards
> Yousaf
>



 
Reply With Quote
 
Zuzeppeddu
Guest
Posts: n/a
 
      3rd Sep 2007
Thanks. Works perfectly.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy and paste 2900 times macro DLB Microsoft Excel Misc 4 15th May 2009 07:20 PM
copy and paste 2900 times macro DLB Microsoft Excel Misc 0 15th May 2009 06:52 PM
Copy and paste not working anywhere in Vista at times Brian Scheele Windows Vista General Discussion 0 19th Feb 2008 08:16 PM
Macro - copy a range and paste it in a new sheet 12 times =?Utf-8?B?RXZh?= Microsoft Excel Worksheet Functions 0 26th Sep 2007 07:20 PM
Select cells copy/paste and repeat x times =?Utf-8?B?TWlrZSBIYW5u?= Microsoft Excel Programming 5 5th Aug 2006 01:55 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:29 AM.