The code below is VBA for Excel. I am using the Visual Basic editor that comes with Excel 2007.
Dim counter As Integer
counter = 1
While counter < 20
counter = counter + 1
end while '<- the compiler is complaining about this statement
The code doesn’t compile. Above the code I have only declarations. According to MSDN this should work but it doesn’t. What has happened?
Whileconstructs are terminated not with anEnd Whilebut with aWend.Note that this information is readily available in the documentation; just press F1. The page you link to deals with Visual Basic .NET, not VBA. While (no pun intended) there is some degree of overlap in syntax between VBA and VB.NET, one can’t just assume that the documentation for the one can be applied directly to the other.
Also in the VBA help file: