Copy and paste macro help

abinayan

New Member
Joined
Jan 28, 2011
Messages
14
Hi guys,

I have data sorted into 2000 rows and 10 columns.

Now I have to copy and paste row 5 cells in row 7 to row 8, row 10 to 11, row 13 to 14 and so on in an interval of three for the rest of the 2000 rows. Can anyone help me with a macro that can do this?

Thanks you very much.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Try this:
Code:
Option Explicit

Sub CopyPasteRow5()
Dim LR As Long
Dim Rw As Long

    LR = Range("A" & Rows.Count).End(xlUp).Row

    For Rw = 7 To LR Step 3
        Rows(5).Copy Range("A" & Rw).Resize(2).EntireRow
    Next Rw

End Sub
 
Upvote 0
Not sure what you mean here.... Why would you need a macro.

wouldnt you just create a reference here.... i.e C3 is =B2, C4 is =B3 and then copy down the formula...?
 
Upvote 0
The problem is I have sensitive data stored in the other three rows which I need to skip without touching, therefore the complication.
 
Upvote 0
Try this:
Code:
Option Explicit
 
Sub CopyPasteRow5()
Dim LR As Long
Dim Rw As Long
 
    LR = Range("A" & Rows.Count).End(xlUp).Row
 
    For Rw = 7 To LR Step 3
        Rows(5).Copy Range("A" & Rw).Resize(2).EntireRow
    Next Rw
 
End Sub


Hi there,

Thank you very much for your reply. When I ran the code the lines just went blank. I only want to copy and paste 5 cells from each row starting from row 7, column G (G7:K7) to (G8:K8) and copy and paste (G10:K10) to (G11:k11) and so on with an interval of 3 rows.

I hope this makes sense.
Cheers.
 
Upvote 0
I misread your entire question, try this:

Code:
Option Explicit

Sub CopyPasteRow5()
Dim LR As Long
Dim Rw As Long

    LR = Range("A" & Rows.Count).End(xlUp).Row

    For Rw = 7 To LR Step 3
        Range("G" & Rw, "K" & Rw).Copy Range("G" & Rw + 1)
    Next Rw

End Sub
 
Upvote 0
I misread your entire question, try this:

Code:
Option Explicit
 
Sub CopyPasteRow5()
Dim LR As Long
Dim Rw As Long
 
    LR = Range("A" & Rows.Count).End(xlUp).Row
 
    For Rw = 7 To LR Step 3
        Range("G" & Rw, "K" & Rw).Copy Range("G" & Rw + 1)
    Next Rw
 
End Sub

Hi JB,

your code worked perfectly fine.. I just made two small changes to make it work for me.
I changed the "LR = Range("A" & Rows.Count).End(xlUp).Row" to "LR = Range("G" & Rows.Count).End(xlUp).Row" to start looking from column G.
and I changed copy to cut since the copied formula updated to a new location which I didnt want.

Thanks very much for your help. Really appreciate it!

cheers
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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