Chris2015
Chris2015

Reputation: 1050

Add a variable within Do Until loop

Can someone explain how to add a variable within a Do Until Loop? I can't quite get mine to work. I am getting an error that says "Next without for". Here is what I have so far:

Application.ScreenUpdating = True

Dim i As Long
For i = 5 To 6

Do Until Sheets("Analysis").Range("L1") < 50 And Sheets("Analysis").Range("N1") < 250000 And Sheets("Analysis").Range("AB" & i) > 0.05


Next i


Application.Calculate

Loop

Thank you!

Upvotes: 1

Views: 53

Answers (1)

Alex
Alex

Reputation: 1642

You are overlapping your loops - I put the Do loop inside the For loop below:

Dim i As Long
For i = 5 To 6

Do Until Sheets("Analysis").Range("L1") < 50 And Sheets("Analysis").Range("N1") < 250000 And Sheets("Analysis").Range("AB" & i) > 0.05
Application.Calculate

Loop
Next i

Upvotes: 1

Related Questions