VBA Do Until

%3CLINGO-SUB%20id%3D%22lingo-sub-3359220%22%20slang%3D%22en-US%22%3EVBA%20Do%20Until%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3359220%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%20i%20have%20a%20code%20Do%20Until%20EOF%20that%20is%20working%20fine%20as%20I've%20created.%3C%2FP%3E%3CP%3ERecently%20i%20just%20wanted%20to%20add%20a%20for%20next%20because%20i%20need%20to%20run%20the%20same%20code%20more%20than%20once.%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20issue%20is%20when%20its%20done%20the%201st%20run%20the%20information%20is%20pulling%20correctly%20from%20the%20source%20in%20this%20case%20Notepads%20to%20excel%20as%20we%20know%20the%20information%20its%20end%20in%20certain%20excel%20line%2C%20when%20its%20starting%20the%202nd%20run%20the%20information%20its%20not%20starting%20in%20line%201%20its%20starting%20on%20the%20next%20line%20of%20last%20run.%20In%20other%20word%20the%201st%20run%20ended%20in%20line%205%20the%202nd%20run%20start%20pulling%20the%20information%20in%20line%206%20when%20the%20code%20should%20start%20in%20the%20line%201.%3C%2FP%3E%3CP%3EI%20placed%20a%20select%20range%20to%20start%20in%20the%201st%20line%20and%20the%20cell%20is%20selected%20but%20the%20info%20is%20not%20starting%20in%20that%20line.%3C%2FP%3E%3CP%3EWhat%20I'm%20missing!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3359220%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3359293%22%20slang%3D%22en-US%22%3ERe%3A%20VBA%20Do%20Until%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3359293%22%20slang%3D%22en-US%22%3EIm%20a%20beginner%20in%20this%20I've%20used%20internet%20and%20youtube%20references%20to%20do%20my%20code%20%3CLI-EMOJI%20id%3D%22lia_slightly-smiling-face%22%20title%3D%22%3Aslightly_smiling_face%3A%22%3E%3C%2FLI-EMOJI%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3359639%22%20slang%3D%22en-US%22%3ERe%3A%20VBA%20Do%20Until%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3359639%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1387310%22%20target%3D%22_blank%22%3E%40MrPenaPr%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3ESub%20fornext()%0A%0ADim%20i%20As%20Integer%0ADim%20j%20As%20Integer%0A%0Ai%20%3D%201%0A%0AFor%20j%20%3D%205%20To%209%0A%0ADo%20Until%20i%20%3D%206%0A%0ACells(i%2C%20j).Value%20%3D%20Cells(i%2C%201).Value%0Ai%20%3D%20i%20%2B%201%0A%0ALoop%0A%0Ai%20%3D%201%0A%0ANext%20j%0A%0A%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EIn%20the%20attached%20file%20you%20can%20click%20the%20button%20in%20cell%20C2%20to%20start%20the%20macro.%20Maybe%20there%20is%20a%20similarity%20to%20what%20you%20want%20to%20do.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3359715%22%20slang%3D%22en-US%22%3ERe%3A%20VBA%20Do%20Until%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3359715%22%20slang%3D%22en-US%22%3EIm%20going%20to%20try%20that!%20But%20my%20code%20is%20little%20more%20complex%20anyways%20because%20im%20using%20a%20open%20path%20close..all%20that%20thanks%3C%2FLINGO-BODY%3E
New 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