1

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!

Community
  • 1
  • 1
Chris2015
  • 1,030
  • 7
  • 28
  • 42

1 Answers1

1

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
Alex
  • 1,632
  • 1
  • 12
  • 28