Simple loop/for/do needed

rossbritton26

New Member
Joined
Jul 28, 2011
Messages
33
Hi,

I am trying to do something that i think is quite simple!!
I am trying to copy a range of cells of size 3to7, repeatedly into a specified column/range, until the thirteen destination cells are full.

e.g
i have range
A
B
C
D

so the thirteen cells would read:
A
B
C
D
A
B
C
D
A
B
C
D
A

if anyone could give me some help it would be much appreciated

please note, the use of A,B,C & D are for illustration purposes only!!
and the number of original cells may change from between 3 and 7.

Thanks
Ross.
 
Last edited:

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
HJere's an example you can adapt. In this example, the data to copy is in Range A2:A5 and the 13 cells to fill by repetitive pastes are D2:D14:
Code:
Sub ThirteenPaste()
Dim rC As Range, rP As Range
Set rC = Range("A2:A5")
Set rP = Range("D2:D14")
rC.Copy
For i = 1 To rP.Rows.Count Step rC.Rows.Count
    If rP.Rows.Count - i > rC.Rows.Count Then
        rP.Rows(i).PasteSpecial Paste:=xlValues
    Else
        rC.Resize(rP.Rows.Count - i + 1).Copy
        rP.Rows(i).PasteSpecial Paste:=xlValues
    End If
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,634
Messages
6,125,938
Members
449,275
Latest member
jacob_mcbride

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top