Question

Hopefully this is relatively straight forward but I am new to VBA. I have two sheets - Sheet1 and Sheet2. In Sheet1 cell B2 I have a blank cell which when populated with a number generates an output in B5.

I want this output to then be pasted to Sheet2 in column A cell A5.

However I am getting stuck as I need to perform this for thousands of inputs in B2. I need to loop through integers 5 all the way to 200000 or so each time recording the result in column A of Sheet2 one below the other.

Is this easy enough to do?

Thanks!

Was it helpful?

Solution

Start this running and then go get a cup of coffee:

Sub reRun()
    Dim L As Long
    Application.ScreenUpdating = False
        For L = 5 To 200000
            Sheets("Sheet1").Range("B2").Value = L
            Sheets("Sheet2").Range("A" & L) = Sheets("Sheet1").Range("B5")
        Next L
    Application.ScreenUpdating = True
End Sub

It will take some time to complete.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top