Reputation: 23
I am trying to copy the values from the same range (G8:G1000), and then paste those values to the next column (H8:H1000). However, I then want to copy that same range (G8:G1000) again, but then paste the values into I8:I1000, and do that at least 100 times. Essentially, there is a formula in column G that is producing randomized values, and I want to copy those unique values into all of the columns following column G. I believe I will need some sort of For Next loop, where it keeps selecting the values from G column, and then pasting them to the next column after the previously pasted into column, but I have very little VBA knowledge to figure this out. Does anyone have a potential solution for this? Any help is appreciated.
Thanks.
Upvotes: 2
Views: 48
Reputation: 54807
Option Explicit
Sub generateColumns()
Const rgAddress As String = "G8:G1000"
Const cCount As Long = 100
Dim rg As Range: Set rg = Range(rgAddress)
'rg.Formula = "=RANDBETWEEN(1,100)"
Application.ScreenUpdating = False
Dim c As Long
For c = 1 To cCount
rg.Offset(, c).Value = rg.Value
Next c
Application.ScreenUpdating = True
End Sub
Upvotes: 1