Inserting multiple rows with copy and paste the existing data

Closed
rameshb_25 Posts 1 Registration date Thursday August 1, 2013 Status Member Last seen August 1, 2013 - Aug 1, 2013 at 11:10 PM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Aug 5, 2013 at 11:44 AM
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 responses

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 552
Aug 5, 2013 at 10:45 AM
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
Hi There

I got that figured out. Thanks.

Ramesh
0
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 552
Aug 5, 2013 at 11:44 AM
Hi Ramesh,

Thanks for letting me know.

Best regards,
Trowa
0