Excel - Repeat Last row into N number of times

Closed
Abu.hamna Posts 1 Registration date Tuesday 28 February 2017 Status Member Last seen 28 February 2017 - 28 Feb 2017 à 08:09
TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 - 28 Feb 2017 à 11:48
Hello,

Can anyone help me to repeat last row into N number of times into same sheet.

Sample Data Where N=5

Column-A Column-B
abc 111
AAA 222


Expected Output.

Column-A Column-B
abc 111
AAA 222
AAA 222
AAA 222
AAA 222
AAA 222
AAA 222
Related:

1 response

TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 555
28 Feb 2017 à 11:48
Hi Abu,

You didn't mentioned where the number N can be found, so I let Excel ask you.

Here is the code:
Sub RunMe()
Dim x, N As Integer
N = InputBox("How many times do you want to repeat the last row?:")
x = Range("A1").End(xlDown).Row

Do Until N = 0
    Rows(x).Copy Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
    N = N - 1
Loop
End Sub


Best regards,
Trowa