Loop to copy and paste

shivam03

Board Regular
Joined
Nov 22, 2010
Messages
86
Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p></o:p>
Thanks for taking time to read this. <o:p></o:p>
<o:p></o:p>
I have thought of solution to a previous question I posted but need some help to get it started. I have some code that copies and pastes a row of data downwards. The issue is that when I get the code to copy the contents of cells B2 to BF2 downwards by more than 650 rows it does not work.<o:p></o:p>
<o:p> </o:p>
Please can someone help me with the following -<o:p></o:p>
<o:p></o:p>
I have the following values in cells B2 to K2.<o:p></o:p>
<o:p></o:p>
1 =B2 =C2 =D2 =E2 =F2 =G2 =H2 =I2 =J2 =K2<o:p></o:p>
<o:p></o:p>
I would like to have the contents of cells B2 to F2 copied down by 10 rows and then cells G2 to K10 by 10 rows.<o:p></o:p>
<o:p></o:p>
I essentially want to have a loop that will do this a number of times. E.g. I might need to copy 50 columns in groups of 5.<o:p></o:p>
<o:p> </o:p>
Eventually I want to have the number of rows it copies downwards as a variable but will keep it simple for now.<o:p></o:p>
<o:p> </o:p>
Thanks a lot<o:p></o:p>
<o:p></o:p>
shivam03
 
I do have calculation of when I do it and it does not help.



I have started to write a loop that work in columns of five. Is there a way of using my old code to replace the second loop (with k).

I want to copy and paste all the rows in one go, not row by row.

Thanks.


Dim k As Long
k = 1
For J = 0 To 15

Sheets("Sheet1").Select
Range("B2:F2").Offset(0, J).Copy

For k = 1 To 10
Range("B2").Offset(k, J).Select
ActiveSheet.Paste
Next k

k = 1
J = J + 4

Next J

End Sub
 
Upvote 0

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
I just realised that I should have specified what I meant by my old code. I have pasted it below.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p></o:p>
Sub test()
Dim lngLastRow As Long

lngLastRow = 500

Sheets("Sheet1").Range("B2:BF2").Copy _
Destination:=Sheets("Sheet1").Range("B2:BF" & lngLastRow)
End Sub <o:p></o:p>

<o:p></o:p>
In my new code I was to see if I can do .Copy and then paste the data accross the all the cells underneath not row by row like the code above.<o:p></o:p>
<o:p></o:p>
Thanks a lot<o:p></o:p>
<o:p></o:p>
shivam03<o:p></o:p>
 
Upvote 0

Forum statistics

Threads
1,224,541
Messages
6,179,418
Members
452,912
Latest member
alicemil

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