Using an Exit Do Statement : Exit « Language Basics « VBA / Excel / Access / Word






Using an Exit Do Statement

 
 Sub Lottery_2()
     Dim sngWin As Single
     Do Until sngWin > 2000
         sngWin = Rnd * 2100
         If sngWin < 500 Then
             Debug.Print "less than 500"
             Exit Do
         End If
         Debug.Print sngWin
     Loop
 End Sub

 








Related examples in the same category

1.Exiting a For...Next Loop Early
2.A Generic Procedure Skeleton with Basic Error Handling