Excel Macro help, copy rows and paste rows X times below [Closed]

Report
Posts
1
Registration date
Thursday May 4, 2017
Status
Member
Last seen
May 4, 2017
-
Posts
2718
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
April 15, 2021
-
Hello,

I need an macro to simply the below operation.
I want to copy below text x times

A B C
D E
F G


If I want to output it 3x, the the output will be

A B C
D E
F G
A B C
D E
F G
A B C
D E
F G

Any help greatly appreciated

1 reply

Posts
2718
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
April 15, 2021
459
Hi KaiDai,

Give the following code a try (assuming data is located over cell A1):
Sub RunMe()
Dim x As Integer

x = InputBox("What is x?", "Output x number of times")

Range("A1").CurrentRegion.Copy

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

Application.CutCopyMode = False
End Sub


Best regards,
Trowa

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!