2

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.

1 Answer 1

1

Generate Columns

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
Sign up to request clarification or add additional context in comments.

1 Comment

Beautiful, that did the trick! Thank you so much!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.