# macro to copy and paste range in next available column 'x' number of times



## hustlethemacro (Dec 22, 2022)

Looking for a macro that will copy a range of data and paste it repeatedly into the next available columns 'x' number of times. The number of times will be specified on another worksheet, cell A1.  In the example below, data was copied from range B1:C4 and pasted into D1:E4 and F1:G4, so 2 times (2 will be the value in cell A1 of the other worksheet). Thx


----------



## rollis13 (Dec 22, 2022)

This macro will copy the selected area to the right X times:
	
	
	
	
	
	



```
Option Explicit
Sub CopyToRight_X_Times()
    Dim x      As Long
    Dim Rng    As Range
    x = Sheets(3).Range("A1")   '<- adjust sheet name as needed
    Set Rng = Selection
    Rng.Copy Rng.Offset(, Rng.Columns.Count).Resize(Rng.Rows.Count, Rng.Columns.Count * x)
End Sub
```


----------



## hustlethemacro (Dec 22, 2022)

rollis13 said:


> This macro will copy the selected area to the right X times:
> 
> 
> 
> ...


This worked perfectly! Thanks!


----------



## rollis13 (Dec 22, 2022)

Thanks for the positive feedback, glad having been of some help.


----------

