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

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,216,077
Messages
6,128,676
Members
449,463
Latest member
Jojomen56

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