VBA Repeat cells

grifdoogindoggy

New Member
Joined
Aug 27, 2019
Messages
21
How would I turn:

A1
A2
A3

Into:

A1
A2
A3
A1
A2
A3

as many times as I want into a different sheet?
 
Last edited:

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Maybe something like this.

Code:
Sub Repeat()
Dim wm As Worksheet: Set wm = Sheets("Sheet1") 'Main Sheet
Dim wn As Worksheet: Set wn = Sheets("Sheet2") 'Sheet to copy to
Dim Times As Long: Times = 5
Dim LR As Long
Dim AR() As Variant: AR = wm.Range("A1:A" & wm.Range("A" & Rows.Count).End(xlUp).Row).Value


For i = 1 To Times
    LR = wn.Range("A" & Rows.Count).End(xlUp).Row + 1
    wn.Range("A" & LR).Resize(UBound(AR), 1).Value = AR
Next i


End Sub
 
Upvote 0
Maybe something like this.

Code:
Sub Repeat()
Dim wm As Worksheet: Set wm = Sheets("Sheet1") 'Main Sheet
Dim wn As Worksheet: Set wn = Sheets("Sheet2") 'Sheet to copy to
Dim Times As Long: Times = 5
Dim LR As Long
Dim AR() As Variant: AR = wm.Range("A1:A" & wm.Range("A" & Rows.Count).End(xlUp).Row).Value


For i = 1 To Times
    LR = wn.Range("A" & Rows.Count).End(xlUp).Row + 1
    wn.Range("A" & LR).Resize(UBound(AR), 1).Value = AR
Next i


End Sub

Thank you! This works well, but for some reason this is printing into the A2 cell and not the A1?
 
Upvote 0
This should do it.

Code:
Sub Repeat()
Dim wm As Worksheet: Set wm = Sheets("Sheet1") 'Main Sheet
Dim wn As Worksheet: Set wn = Sheets("Sheet2") 'Sheet to copy to
Dim Times As Long: Times = 5
Dim LR As Long
Dim AR() As Variant: AR = wm.Range("A1:A" & wm.Range("A" & Rows.Count).End(xlUp).Row).Value


For i = 1 To Times
    If i = 1 Then
        LR = wn.Range("A" & Rows.Count).End(xlUp).Row
    Else
        LR = wn.Range("A" & Rows.Count).End(xlUp).Row + 1
    End If
    wn.Range("A" & LR).Resize(UBound(AR), 1).Value = AR
Next i


End Sub
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,619
Latest member
Shiv1198

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