make excel copy a row and automatically insert new rows

R

Robin

How do I make excel copy a row and then automatically insert new rows that
are copies of that row based on a number input by a user (i.e. a user unoyuts
'10' in a cell excel copies the content of row 51 abd then inserts 10 new
rows that are copies of row 51)?
 
D

Don Guillett

Sub copyrows()
numrows = InputBox("Number of rows")
'Rows(ActiveCell.Row).Copy ActiveCell.Resize(numrows)
Rows(ActiveCell.Row).Copy
ActiveCell.Resize(numrows).Insert
Application.CutCopyMode = False
End Sub
 
R

Robin

Don,
Thank you for your help.
Was able to get your code to work (copy and insert rows in Excel). It
worked good. I do have a follow-on question. Is there a way to get one of
the copied cells to increment based on a starting number in the row to be
copied? In other words, in the row to be copied there is a cell with a value
of '1' and we need that value to be incremented for each new row that is
inserted. So, if we have Excel insert ten additional rows, that number
should be incremented from '1' in the copied row all the way to '11' in the
newly inserted rows.
Sincerely,

Robin

Does that make sense?
 

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