Copy all rows in a sheet and paste multiple times below in the same sheet

anglais428

Well-known Member
Joined
Nov 23, 2009
Messages
634
Office Version
  1. 2016
Platform
  1. Windows
Hi Guys,

I am looking at taking the following:
[TABLE="width: 500"]
<tbody>[TR]
[TD]A[/TD]
[TD]100[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]500[/TD]
[/TR]
[TR]
[TD]C[/TD]
[TD]250[/TD]
[/TR]
</tbody>[/TABLE]

and replicating it (full rows) by 'X' times. I would like a Message Box to ask for the number of times it should be replicated.
If the user was to enter '2' then, on the same Sheet, it should look like:

[TABLE="width: 500"]
<tbody>[TR]
[TD]A[/TD]
[TD]100[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]500[/TD]
[/TR]
[TR]
[TD]C[/TD]
[TD]250[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]100[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]500[/TD]
[/TR]
[TR]
[TD]C[/TD]
[TD]250[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]100[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]500[/TD]
[/TR]
[TR]
[TD]C[/TD]
[TD]250[/TD]
[/TR]
</tbody>[/TABLE]

i.e. the original plus the 2 duplicates.
Ideally, I would like this to be a VBA solution as the number of rows is very large.
Thanks,
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Try

Code:
Sub test()
Dim LR As Long, i As Long, x As String
LR = Range("A" & Rows.Count).End(xlUp).Row
x = InputBox("How many times?")
Range("A1:B" & LR).Copy
For i = 1 To x
    Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,225,065
Messages
6,182,653
Members
453,130
Latest member
alexos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top