I need to insert a random number of rows in excel and fill the cell value incrementally by one on each row.
I found the following formula that inserts the blanks rows and copies the value to each row. I want the value to increment by 1 for each new row. It prompts the user for the number of rows to add. But it inserts the row and copies the value down. I need the value to be copied down but add one to the value each time it is copied.
Ex prompt for the number of rows to insert. User enters value of 3. So 3 rows should be inserted. If the value was 111 the next row the cell value would be 112 and the next would be 113, the next 114
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
Thanks for any help that can be provided.
I found the following formula that inserts the blanks rows and copies the value to each row. I want the value to increment by 1 for each new row. It prompts the user for the number of rows to add. But it inserts the row and copies the value down. I need the value to be copied down but add one to the value each time it is copied.
Ex prompt for the number of rows to insert. User enters value of 3. So 3 rows should be inserted. If the value was 111 the next row the cell value would be 112 and the next would be 113, the next 114
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
Thanks for any help that can be provided.