How to copy a range n times

Waimea

Active Member
Joined
Jun 30, 2018
Messages
465
Office Version
  1. 365
Platform
  1. Windows
I am trying to copy a range ("A2:H41") 40 times down but I would also like the choice to copy it a range x times down.

Code:
Sub CopyMeTimesDown
   
    Dim rng As range
    Set rng = range("A2:H41")
    Dim batchSize As Integer
    Set batchSize = 40
    Dim x As Integer
        
    rng.Select
    For x = 1 To 1601 Step batchSize
         ActiveSheet.Paste
    Next x
    
End Sub

I can't get this to work, what am I doing wrong?
 
Last edited:
This is what I love about this community. In the time it took me to write up a small loop the way I would have addressed the problem, Fluff gives a highly efficient solution that teaches me something new. I didn't even know about the InputBox function.

If you want a box to pop up asking for a number, just change where you set the nmbr variable.
 
Upvote 0

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,215,438
Messages
6,124,873
Members
449,192
Latest member
MoonDancer

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