I have been programming for a ‘few years’ and feel that I can generally get things done. However, I just ran into a problem in Excel VBA that makes literally no sense to me. Here is the code (simplified to just show the issue):
Code:
Sub testme()
    Dim i, j As Integer
    For i = 1 To 10
        Do
        While j > 5
    Next i ‘ ** this line
End Sub
When I click Debug->Compile VBA Project, it shows: ‘Compile error: Next without For’ on the line indicated.

This makes less than no sense as the code is perfectly reasonable. What the heck is going on??? More importantly, how can I use this trivial construct in my code and make it work?