Copying and pasting a range of cells n times.

Calitri

New Member
Joined
Apr 23, 2011
Messages
1
hI ALL,

I NEED A MACRO that copies a range of cells say from c1 to c3 six times in Column F.
say if the value in the range C1 To C3 is a b c.The range F1:F18 should have the value a b c a b c a b c a b c a b c a b c.

Please reply..urgent and advanced thanks...!
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Try

Code:
Sub copy6()
Dim i As Long
Range("C1:C3").Copy
For i = 1 To 6
    Range("F" & 3 * i - 2).PasteSpecial Paste:=xlPasteValues
Next i
End Sub
 
Upvote 0
Should be able to do all the multiples at once. Depending on whether you can do with Paste or need PasteSpecial ..

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> Copy_N_a()<br>    <SPAN style="color:#00007F">Const</SPAN> myMult <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN> = 6 <SPAN style="color:#007F00">'<-Change to suit</SPAN><br>    <br>    <SPAN style="color:#00007F">With</SPAN> Range("C1:C3")<br>        .Copy Destination:=Range("F1").Resize(.Rows.Count * myMult)<br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br><br><SPAN style="color:#00007F">Sub</SPAN> Copy_N_b()<br>    <SPAN style="color:#00007F">Const</SPAN> myMult <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN> = 6 <SPAN style="color:#007F00">'<-Change to suit</SPAN><br>    <br>    <SPAN style="color:#00007F">With</SPAN> Range("C1:C3")<br>        .Copy<br>        Range("F1").Resize(.Rows.Count * myMult).PasteSpecial Paste:=xlPasteValues<br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>    Application.CutCopyMode = <SPAN style="color:#00007F">False</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 
Upvote 0
Hi,
Is there a way to insert a input box in the place of Const myMult As Long = 6 '<-Change to suit ??
I want the user to enter the number of times they want the data to be copy pasted. One time it can be 6, other time it can be 60.

Thanks,
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,752
Members
452,940
Latest member
rootytrip

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