Copy a list n times

Jordan22

New Member
Joined
Aug 31, 2020
Messages
11
Office Version
  1. 365
Platform
  1. Windows
Hello

I am totally new in macro's world so i would like to ask a little' help

I have a list in column of A, A2:A?? (so the cell of last data is always different).
I would like to copy that list x times into a new sheet (it would be awesome if i would give a number in a cell to tell how many times should it does)

So in A column (Sheet1)
A1: A
A2: B
A3: C
Ax: PO

And i would like to see this list on a new worksheet x times under each other without empty lines (Sheet2)


Thank you! :)
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Hello,

does this work as expected?

VBA Code:
Sub copy()
    MY_NO = InputBox("How many copies?", "SELECT NO OF COPIES")
    Application.ScreenUpdating = False
    For MY_COPIES = 1 To MY_NO
        Sheets("Sheet1").Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row).copy
        Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial (xlPasteAll)
    Next MY_COPIES
    Application.ScreenUpdating = True
    Application.CutCopyMode = False
End Sub
 
Upvote 0
Sorry, but i would have an another little question, if you have time.
I would like to start the paste from the 5th line and not from the second, if i try to change the "Offset(1, 0)" to "offset(4,0)" it creates empty lines too between of repeat. :confused: Of course i tried to change the "
Range("A")" too, but it wasnt succes.
 
Upvote 0
Thank you! :) It's perfect :D Better than my insert some empty rows ideas. :)
 
Upvote 0
Another option, without loops
VBA Code:
Sub Jordan()
   Dim Rng As Range
   Dim Rws As Variant
  
   Rws = InputBox("How many copies do you want")
   If Rws = "" Then Exit Sub
  
   With Sheets("Sheet1")
      Set Rng = .Range("A2", .Range("A" & Rows.Count).End(xlUp))
   End With
   Rng.Copy Sheets("Sheet2").Range("A5").Resize(Rng.Count * Rws)
End Sub

Also with the code from onlyadrafter if you are not on Sheet1 when you run the code, it will fail.
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,873
Members
449,056
Latest member
ruhulaminappu

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