Macro to Paste Selection Every 12 Rows

garygraham

New Member
Joined
Jun 28, 2011
Messages
13
I'm new to macros but trying to learn. Thanks in advance for your help.

I'm trying to copy a range of cells A3:G3 (with formulas) and then paste it every 12 rows to the end of the data which is row 67,789. In other words the range A3:G3 would be pasted into A15, A27, A39, A51, etc. all the way to A67,789.

Thanks,
Gary
 
That created a spreadsheet with > 1M rows.

Maybe I'm not going about this in the best way. Let me explain what I'm trying to accomplish and you tell me what the best method is.

https://picasaweb.google.com/lh/photo/O6Mh3NUgpWHuec1IwaRHjw?feat=directlink

Post





The red rows (Jan Data) already exists for each customer.
The yellow rows simply reference the row above for customer info for data months Feb - Dec. I want to copy those formula from the yellow rows to the green sections below such that the respective red rows in each section are copied to the green sections. Have I totally confused you yet??? :laugh:

Thanks,
Gary




O6Mh3NUgpWHuec1IwaRHjw
 
Upvote 0

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Yes but it has to paste the formulas such that they pick up the data from the red rows in each respective section.

Thanks,
Gary
 
Upvote 0
Hi Gary,

Here's my attempt, which like Balde Hunter said will take a while to run:

Code:
Sub Macro2()

    Dim lngLastRow As Long, _
        lngPasteRow As Long
    
    lngLastRow = Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row

    Application.ScreenUpdating = False
    
    For lngPasteRow = 2 To lngLastRow Step 12
        If lngPasteRow > 2 Then
            Range("A2:G2").Copy Destination:=Range("A" & lngPasteRow & ":G" & lngPasteRow)
        End If
    Next lngPasteRow
    
    Application.ScreenUpdating = True

End Sub

HTH

Robert
 
Last edited:
Upvote 0
I built a very basic but very long macro that I had to break into multiple parts that I think got the job done.

Thanks guys, I'll give your much better solution a shot tomorrow.
It's after 2:00 Am here and I'm going to bed.

Thanks again for all the help.
Gary
 
Upvote 0
Hi Gary,

It's done the job - i.e. copied the range A2:G2 to every 12th row.

Do you need the range to be A2:G13?

Robert
 
Upvote 0

Forum statistics

Threads
1,224,507
Messages
6,179,176
Members
452,893
Latest member
denay

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