macro to paste formulas every 5 rows

drewbny

Board Regular
Joined
Jan 16, 2011
Messages
98
how do i create a macro to paste a row of formulas to every 5th row?.
in another words i want the formulas to not get pasted over the next 4 rows and paste on the 5th row. then keep doing that within a certain range of data.

also can i do with a range of data?
so lets say i want to paste three rows of data, i can do that to every 5th row?
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
how do i create a macro to paste a row of formulas to every 5th row?.
in another words i want the formulas to not get pasted over the next 4 rows and paste on the 5th row. then keep doing that within a certain range of data.

also can i do with a range of data?
so lets say i want to paste three rows of data, i can do that to every 5th row?
Hello Drew,

The code below will copy a range and paste it every 5 rows.

VBA Code:
Sub copyrangetofive()
Dim i As Integer
i = 5
    For i = 5 To 100 'Change the 100 to the last row you wish to copy to
    Range("A1:D3").Copy Cells(i, 1) 'Change Range("A1:D3") to the range you wish to copy
    i = i + 5
    Next i
End Sub

The green text is just comments - you can delete them without worry. :)

Jamie McMillan
 
Upvote 0
Solution
Hello Drew,

The code below will copy a range and paste it every 5 rows.

VBA Code:
Sub copyrangetofive()
Dim i As Integer
i = 5
    For i = 5 To 100 'Change the 100 to the last row you wish to copy to
    Range("A1:D3").Copy Cells(i, 1) 'Change Range("A1:D3") to the range you wish to copy
    i = i + 5
    Next i
End Sub

The green text is just comments - you can delete them without worry. :)

Jamie McMillan
This is awesome!! Thank you.
Wish Excel had this feature built in to insert, paste or remove multiple rows easily without manually selecting the rows
 
Upvote 0

Forum statistics

Threads
1,214,584
Messages
6,120,384
Members
448,956
Latest member
JPav

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