Copy Paste to Every Nth Row

alexb523

Board Regular
Joined
Dec 12, 2013
Messages
115
Hello,

I am having issues copying the same thing 'n' amount of times to every 'n' row. i have a range of cells and would like to post it every over and over again (i have a code to get the respective values). I do this several different times and paste it a different amount of times. Here is the 'hard code' of what i need done:

Code:
    'Count of Mode
    Dim modeTable As Worksheet
    Set modeTable = Sheets.Add(After:=Sheets(Worksheets.Count))
    modeTable.Name = "modeTable"
    
    TableTemplates.Range("A67:G84").Copy
    
    modeTable.Range("A2").Select
    ActiveSheet.Paste
    modeTable.Range("A21").Select
    ActiveSheet.Paste
    modeTable.Range("A40").Select
    ActiveSheet.Paste
    modeTable.Range("A59").Select
    ActiveSheet.Paste
    modeTable.Range("A78").Select
    ActiveSheet.Paste
    modeTable.Range("A97").Select
    ActiveSheet.Paste
    modeTable.Range("A116").Select
    ActiveSheet.Paste
    modeTable.Range("A135").Select
    ActiveSheet.Paste
    modeTable.Range("A154").Select
    ActiveSheet.Paste
    modeTable.Range("A173").Select
    ActiveSheet.Paste
    modeTable.Range("A192").Select
    ActiveSheet.Paste
    modeTable.Range("A211").Select
    ActiveSheet.Paste
    modeTable.Range("A230").Select
    ActiveSheet.Paste
    modeTable.Range("A249").Select
    ActiveSheet.Paste


and then here is my attempt loop it. but i keep getting errors every which way.



Code:
    'count number of 'Count of Mode' table needed
    TableNames.Select
    Dim modeCount As Integer
    Dim tableRowDiff As Integer
    modeCount = Application.WorksheetFunction.CountIf(Range("A2:A" & lrTableNames), "Count of Mode") 'how many times i need to post a new table resides on a different spreadsheet
    tableRowDiff = 19
    
    For modeRow = 1 To modeCount
        modeTable.Range("A" & (modeRow * tableRowDiff)).Select
        ActiveSheet.Paste
    Next modeRow
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Forum statistics

Threads
1,223,910
Messages
6,175,318
Members
452,634
Latest member
cpostell

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