VBA Compiler Error shows Next Without For

Please Help me to Solve this issue

For E = 17 To 21
If Cells(E, 8) <> 0 Or “” Then
Cells(E, 5).FormulaR1C1 = "By"
Else
Cells(E, 5).Value = ""
Next
End If

Compiler Error shows
Next With out For

Top Contributor Asked on July 22, 2015 in VBA: Basics.
Add Comment
1 Answer(s)

The order of closing For and If statements

For E = 17 To 21
If Cells(E, 8) <> 0 Or “” Then
Cells(E, 5).FormulaR1C1 = "By"
Else
Cells(E, 5).Value = ""
End If
Next

If condition starts after for statement, so it should close before you close For statement.

For ---------->
If=========>
End If<=====
Next <--------

Thanks-PNRao!

Keymaster Answered on July 23, 2015.

thanks for u r correction

on July 23, 2015.
Add Comment
  • Found this useful?

    Please share using the share button above.

    If you found the answer is best answer for your question, Please mark as 'best answer' by clicking on the right tick mark icon at the left side of the answer.

    Found the answer useful and wants to credit the user, then vote the answer (vote up).

  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.