VBA help needed for copy & pasteing a range every 14 rows

bigaz_123

New Member
Joined
Oct 17, 2017
Messages
3
good afternoon everyone.

can you please help me, I have a data set & I need to copy A1:Z14 & paste as value stating at A35, I need to repeat this until the last populated row - 7 rows.

can anyone help me?
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Welcome to the board.

When macro runs:
First time copy A1:Z14 to A35 (i.e. A35:Z48)
Second time copy A1:Z14 to A40?
Continue until you reach the last populated row - 7 (e.g. if last row is 100, stop if the last pasted value is in row 93 or higher?)

Perhaps you can explain further, difficult to understand without seeing your sheet.

What column contains the last populated row?
 
Upvote 0
hi Jack.

Its a strange data set, is there a way of attaching the sheet so I can show you what needs to happen? ps the ranges I gave were for ref only they are actually JZ1:NQ14, I would like to paste the first one in to JZ35 then JZ49 and so on, currently the last cell to paste in to is JZ3493 but this reange need to be dynamic as this expands with new records.

regards,
 
Upvote 0
If you go to the Forum rules on this board, you'll find links to posting code, screenshots etc.

That's fine giving ranges for reference, but what column determines what the last row is, JI or A or other?

As a guess, test on a copy of your worksheet/workbook:
Rich (BB code):
Sub RePopulate()

    Dim LR      As Long
    Dim x       As Long
    Dim arr()   As Variant
    
    'Write area JZ1:NQ14 into an array, where column JZ= 286
    arr = Cells(1, 286).Resize(14, 96).Value
    
    'Determine last row based on column JY
    LR = Cells(Rows.count, 285).End(xlUp).row
    'Reduce last row by 7
    LR = LR - 7
    
    Application.ScreenUpdating = False
        
    'Loop over range and paste values every 14 rows from array
    For x = 35 To LR Step 14 
        Cells(x, 286).Resize(UBound(arr, 1), UBound(arr, 2)).Value = arr
    Next x
    
    Application.ScreenUpdating = True
    
    Erase arr
    
End Sub
 
Last edited:
Upvote 0
Another option
Code:
Sub CopyPaste()

    Dim UsdRws As Long
    
    UsdRws = Cells.Find("*", After:=Range("A1"), SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    UsdRws = UsdRws / 14
    Range("M1:V14").Copy Range("M35").Resize(14 * UsdRws)

End Sub
Change ranges to suit
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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