VBA Do Until

Copper Contributor

Hi, i have a code Do Until EOF that is working fine as I've created.

Recently i just wanted to add a for next because i need to run the same code more than once. 

The issue is when its done the 1st run the information is pulling correctly from the source in this case Notepads to excel as we know the information its end in certain excel line, when its starting the 2nd run the information its not starting in line 1 its starting on the next line of last run. In other word the 1st run ended in line 5 the 2nd run start pulling the information in line 6 when the code should start in the line 1.

I placed a select range to start in the 1st line and the cell is selected but the info is not starting in that line.

What I'm missing!

3 Replies
Im a beginner in this I've used internet and youtube references to do my code :)

@MrPenaPr 

Sub fornext()

Dim i As Integer
Dim j As Integer

i = 1

For j = 5 To 9

Do Until i = 6

Cells(i, j).Value = Cells(i, 1).Value
i = i + 1

Loop

i = 1

Next j


End Sub

In the attached file you can click the button in cell C2 to start the macro. Maybe there is a similarity to what you want to do.

Im going to try that! But my code is little more complex anyways because im using a open path close..all that thanks