Thread: [Solved] How to a For loop in VBA
View Single Post
 
Old 01-28-2013, 10:36 PM
Jennifer Murphy's Avatar
Jennifer Murphy Jennifer Murphy is offline Windows XP Office 2007
Competent Performer
 
Join Date: Aug 2011
Location: Silicon Valley
Posts: 234
Jennifer Murphy is on a distinguished road
Default How to a For loop in VBA

In Visual Basic, the Continue statement will complete the current iteration of a loop and start the next, if any.

Code:
For i = 1 to 10
   ...do some work
   If [some condition] then Continue For
   ...do the rest of the work
Next i
In VBA, the Continue statement gets flagged as invalid.

What's the proper way to end just the current iteration of a For loop in VBA without exiting the loop entirely (Exit Loop)?

Is this different for VBA under Word vs under Excel?

Last edited by Jennifer Murphy; 01-28-2013 at 11:02 PM. Reason: Fixed typo (End For)
Reply With Quote