Inserting multiple rows with copy and paste the existing data

Closed
rameshb_25 Posts 1 Registration date Thursday 1 August 2013 Status Member Last seen 1 August 2013 - 1 Aug 2013 à 23:10
TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 - 5 Aug 2013 à 11:44
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 12 September 2010 Status Contributor Last seen 27 December 2022 555
5 Aug 2013 à 10:45
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
Hi There

I got that figured out. Thanks.

Ramesh
TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 555
5 Aug 2013 à 11:44
Hi Ramesh,

Thanks for letting me know.

Best regards,
Trowa