copy/inserting rows at specific intervals

M

mark

I need to let a user input a number corresponding to the
number of samples (e.g., 1-5).

TO do this I plan on copying a series of rows (acting as a
template) for example 4-9 and then paste this in starting
at row 10 for each sample. So I would have identical rows
starting at 4, 10, 15, etc (based on the user input)

I can capture the user input and copy the 'template' rows
with no problem. My question is how do I 'insert copies'
at specific rows multiple times?

Thanks for your help - Mark.
 
D

Dick Kusleika

Mark

Something like this, I think

Sub MakeTemplate()

Dim NoOfCopies As Long
Dim i As Long

NoOfCopies = Application.InputBox("Enter number of samples")

For i = 10 To (NoOfCopies * 5 + 5) Step 5
Range("A4:A8").EntireRow.Copy
Range("a" & i).Resize(5).EntireRow.PasteSpecial
Next i

Application.CutCopyMode = False

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top