PDA

View Full Version : copy and paste a certain number of times



learn_pt_lx
01-31-2018, 03:29 AM
Hello,

I am working with Page Layout view in Excel.

I want to copy a page to the next empty page, and then copy that pasted page and copy to the next empty page (the page has some formulas that connects to the last of his page). I want the code to copy and paste a certain number of times, it can be for example 5 or 10 to in the end have 10 pages.

The code i am using is the following, but it just adds one new page.
-------------------
Sub copy()Dim i As Integer
i = 1


Do While i < 6

i = i + 1
Loop


Range("K1:T54").copy Range("U1:AD54")

Application.CutCopyMode = False

End Sub
-----------------------------

p45cal
01-31-2018, 03:53 AM
Sub copy()
Dim i As Integer, RngToCopy As Range
Set RngToCopy = Range("K1:T54")
i = 1
Do While i < 6
RngToCopy.copy RngToCopy.Offset(, 10)
Set RngToCopy = RngToCopy.Offset(, 10)
i = i + 1
Loop
End Sub

learn_pt_lx
01-31-2018, 04:33 AM
Holly molly!

Simple code.
Thank you very much p45cal