Inserting multiple rows with copy and paste the existing data

Closed
Report
Posts
1
Registration date
Thursday August 1, 2013
Status
Member
Last seen
August 1, 2013
-
Posts
2829
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
November 22, 2021
-
Hi

The below code works fine with inserting new rows but I need an extension of the code to incorporate copy and paste function on the existing row data. Please help.

Sub test()
Dim j As Long, r As Range
j = InputBox("type the number of rows to be inserted")
Set r = Range("A2")
Do
Range(r.Offset(1, 0), r.Offset(j, 0)).EntireRow.Insert
Set r = Cells(r.Row + j + 1, 1)
If r.Offset(1, 0) = "" Then Exit Do
Loop

End Sub

3 replies

Posts
2829
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
November 22, 2021
490
Hi Rameshb,

Which row would you like to copy (row 2?).
And where would you like to paste that row (rows 3:j ?).

Best regards,
Trowa
2
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 2821 users have said thank you to us this month

Hi There

I got that figured out. Thanks.

Ramesh
Posts
2829
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
November 22, 2021
490
Hi Ramesh,

Thanks for letting me know.

Best regards,
Trowa