“While .. End While” doesn't work in VBA?

前端 未结 2 388
北荒
北荒 2020-12-16 09:56

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
           


        
2条回答
  •  一向
    一向 (楼主)
    2020-12-16 10:47

    VBA is not VB/VB.NET

    The correct reference to use is Do..Loop Statement (VBA). Also see the article Excel VBA For, Do While, and Do Until. One way to write this is:

    Do While counter < 20
        counter = counter + 1
    Loop
    

    (But a For..Next might be more appropriate here.)

    Happy coding.

提交回复
热议问题