vba infinite loop code example

Example: excel vba exit do loop infinite

'VBA has the Exit Do statement to exit a Do Loop:

Do
    c = c + 1
    If c = 750 Then Exit Do
Loop While i < 1000

'-------------------------------------------------------------------
'Note:      If multiple Do Loops are nested, Exit Do transfers
'           control to the next higher level of nesting.
'-------------------------------------------------------------------
 
'VBA also has analogous Exit statement for
'For Next and For Each loops.    
      
'VBA does NOT have an Exit statement for While Wend loops.

Tags:

Vb Example