Loop columns copy/paste

Keala

New Member
Joined
Jul 9, 2018
Messages
37
My question is probably very easy for someone who knows VBA more then me.

I have *.xls file with five columns each column is x rows (let say 40000 rows ). I need to copy 200 rows from column D sheet 1 to sheet 2 column B. Then copy next 200 rows from sheet 1 and paste it in sheet 2 column C and so on until last row.

I can record below way but to copy paste for each 200 is not a good way. I think a loop or a for would be much better, but can't make it my self.

Any suggestions or link to a similar problem with solution is appreciated.

Thank you,

Code:
Sheets("Sheet1").Select
    Range("D46:D246").Select
    Selection.Copy
    Sheets("Sheet2").Select
    Range("B3").Select
    ActiveSheet.Paste
    
    Sheets("Sheet1").Select
    Range("D247:D447").Select
    Selection.Copy
    Sheets("Sheet2").Select
    Range("c3").Select
    ActiveSheet.Paste
    
    Sheets("Sheet1").Select
    Range("D448:D648").Select
    Selection.Copy
    Sheets("Sheet2").Select
    Range("d3").Select
    ActiveSheet.Paste
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
How about
Code:
Sub Keala()
   Dim i As Long, x As Long
   
   x = 1
   With Sheets("Sheet1")
      For i = 46 To .Range("D" & Rows.Count).End(xlUp).Row Step 200
         x = x + 1
         .Cells(i, 4).Resize(200).Copy Sheets("Sheet2").Cells(3, x)
      Next i
   End With
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,891
Messages
6,175,229
Members
452,621
Latest member
Laura_PinksBTHFT

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