VBA Jump to Next Loop: How to Skip an Iteration

VBA & macros · Updated November 18, 2026

VBA has no built-in Continue For or Continue Do statement. To jump to the next loop iteration, put the remaining work inside an If block so it runs only when appropriate; when that is impractical, use GoTo to jump to a label immediately before the loop’s Next or Loop.

What “continue” means in VBA

In a loop, continuing usually means: stop processing the current item, then let the loop advance to its next item. For example, a macro might inspect a list of values but do nothing with blanks or negative numbers. In languages such as VB.NET, a dedicated continue statement can skip the rest of the current pass. VBA does not provide that statement, so you need to arrange the loop body to achieve the same result.

The key distinction is between skipping one iteration and leaving the loop altogether. VBA’s Exit For leaves a For or For Each loop immediately; Exit Do leaves a Do loop. Neither means “go to the next item.” Choosing the wrong one can make a macro stop processing much earlier than intended.

For most routines, the clearest solution is to test whether an item should be processed and put the work inside an If block. A label with GoTo is a useful fallback when deeply nested conditions make that structure awkward.

Prefer an If block for ordinary loops

Rather than trying to jump over code, make the code conditional. The loop still reaches its normal Next statement, which advances the counter. Here is a complete example that adds positive values and ignores zero or negative values:

Sub AddPositiveValues()
    Dim values As Variant
    Dim i As Long
    Dim total As Double

    ' Example data; the total of positive values is 25.
    values = Array(12, -3, 8, 0, 5)
    total = 0

    For i = LBound(values) To UBound(values)
        If values(i) > 0 Then
            total = total + CDbl(values(i))
        End If
    Next i

    Debug.Print total
End Sub

The test makes the intended rule visible: only values greater than zero reach the addition statement. The loop counter still advances for every array element, including those that are ignored. This approach is generally easier to read, indent, and maintain than a jump to a label.

You can also reverse the condition when that reads more naturally. For example, put the main work inside If Not IsEmpty(cell.Value) Then when you want to process non-empty cells. Be careful with cells containing formulas that return an empty string: IsEmpty is not the same as checking whether a displayed cell looks blank. If that distinction matters, choose a test that matches the data, such as comparing the cell’s value to an empty string.

Use GoTo when a jump is genuinely clearer

VBA’s GoTo statement can jump to a named label within the same procedure. For a continue-like pattern, place the label at the end of the loop body, immediately before Next or Loop. When execution reaches the label, the loop proceeds normally. A label should have a descriptive, unique name in its procedure.

Save a copy of the workbook before running a macro. VBA macros cannot be undone with Ctrl+Z, and a macro that edits cells may make changes that are difficult to reverse. The following example demonstrates the pattern; it prints the sum of positive array entries, which is 25:

Sub AddPositiveValuesWithGoTo()
    Dim values As Variant
    Dim i As Long
    Dim total As Double

    ' Example data; skip values that are not positive.
    values = Array(12, -3, 8, 0, 5)
    total = 0

    For i = LBound(values) To UBound(values)
        If values(i) <= 0 Then GoTo NextValue
        total = total + CDbl(values(i))
NextValue:
    Next i

    Debug.Print total
End Sub

Here the jump bypasses only the addition for the current value. It does not jump outside the loop, and it does not prevent the For counter from advancing. Keep the jump short and local: a label far away from the loop makes it harder to see which statements are skipped. If the loop has several different skip conditions, multiple jumps can make the control flow confusing; consider combining the conditions or using an If block instead.

Skipping items in For Each loops

A For Each loop visits each member of a collection or each element in an array. The same two approaches apply: conditionally run the work, or jump to a label just before Next. A conditional is usually the clearest choice when the reason to skip is simple.

For example, when processing worksheet rows, you might handle only rows whose status column says “Ready.” Put the row-processing statements inside an If test for that status; the loop will then move on to the next row whether the test succeeds or not. In a cell-based loop, make sure the range and worksheet are explicitly identified if the active sheet might change while the macro runs.

There is an important extra consideration when the collection itself is being changed. Removing items from a collection or deleting worksheet rows while iterating can affect which item is visited next. A continue-style jump does not solve that problem. For a collection you control, consider iterating backward when removing indexed items; for worksheet rows, deleting from the bottom upward is a common way to avoid shifting unprocessed rows. The right method depends on the collection and the operation, so do not treat skipping and deleting as interchangeable.

Do loops and the importance of updating the condition

In a Do While or Do Until loop, the equivalent destination is a label just before Loop. But a jump must not bypass code that updates the loop’s counter or changes the condition. If it does, the loop may repeat forever. For that reason, arrange essential updates so they happen on every pass, including passes where the item is skipped.

This example advances the counter whether the value is positive or not. It processes only positive values, while the increment remains outside the conditional block:

Sub ProcessPositiveValues()
    Dim values As Variant
    Dim i As Long
    Dim total As Double

    ' The counter advances for every array element.
    values = Array(12, -3, 8, 0, 5)
    i = LBound(values)
    total = 0

    Do While i <= UBound(values)
        If values(i) > 0 Then
            total = total + CDbl(values(i))
        End If
        i = i + 1
    Loop

    Debug.Print total
End Sub

If you use GoTo in a Do loop, put the label after any per-iteration updates that must always run, or keep those updates before the possible jump. Think through the path for a skipped item: will the condition eventually become false? This simple check catches a common source of infinite loops.

Continue For, Exit For, and GoTo compared

These statements and patterns do different jobs. VBA code that uses a statement from another language may fail to compile, even when the intent seems obvious.

  • Continue For: not a supported VBA statement. VBA does not have a native continue command for its loop types.
  • Exit For: stops the current For or For Each loop immediately. Use it when the loop has finished its task or there is no reason to examine later items.
  • Exit Do: stops the current Do loop immediately. It does not skip just the current pass.
  • An If block: usually the most readable way to run work only for items that meet a condition.
  • GoTo and a nearby label: skips statements in the current pass and then reaches the loop’s normal advance point.

For example, if you are searching for the first matching record, finding it may be a reason to use Exit For. If you are collecting every matching record, a non-match should usually skip that record’s processing without ending the loop. The goal of the routine, not just the word “skip,” determines which control flow is correct.

Nested loops and common mistakes

In nested loops, a continue-style jump should go to the end of the loop you intend to continue. A label before the inner loop’s Next columnIndex advances to the next column, while a label before the outer loop’s Next rowIndex advances to the next row. Those are different actions. Name labels clearly, such as NextColumn and NextRow, and avoid reusing a label name within the same procedure.

Before adding a jump, check these frequent mistakes:

  • Using Exit For when only the current item should be skipped. This ends the loop rather than continuing it.
  • Placing a label after code that should still run for every iteration, such as a counter update or cleanup step.
  • Jumping to the wrong loop’s label in nested loops, which can skip more work than intended.
  • Assuming that On Error Resume Next is a continue statement. It suppresses certain runtime errors; it does not provide a safe, targeted way to skip a loop pass, and it can conceal bugs.
  • Writing Continue For because it exists in another Visual Basic dialect. It is not valid VBA syntax.

When a jump is necessary, keep it within the same procedure and make the destination obvious. A reader should be able to identify, without tracing several distant labels, which statements are bypassed and where the loop resumes.

Testing and running the macro safely

To inspect or edit VBA in desktop Excel for Microsoft 365 on Windows, press Alt+F11 to open the Visual Basic Editor. On a Mac, the editor shortcut is commonly Option+F11; depending on the keyboard, you may also need to hold Fn. You can also open the editor from Excel’s Developer tab. Add a procedure to a standard module, then run it from the editor or from Excel’s macro tools.

Test the loop with a small, known set of inputs before applying it to important workbook data. Include examples that should be processed and examples that should be skipped. For a loop that can change cells, first work on a copy and confirm the target worksheet, range, and skip condition. Save a macro-enabled workbook as .xlsm if you need to keep the VBA code in the file. Remember that Ctrl+Z cannot undo changes made by a macro; close without saving or restore a backup if a test makes unwanted edits.

Frequently Asked Questions

Does VBA support Continue For?
No. VBA does not have a built-in Continue For statement. Use an If block to conditionally run the rest of the loop body, or use a nearby GoTo label when a direct skip is clearer.

How do I skip to the next Do While iteration in VBA?
Usually, put the work inside an If block and make sure the counter or other loop condition is updated on every pass. A GoTo label before Loop can also skip the remaining work, but do not let the jump bypass an essential update.

Does Exit For go to the next item?
No. Exit For leaves the entire current For or For Each loop. To skip only one item, use a conditional block or a continue-style label.

Is GoTo bad in VBA?
Not automatically. A short jump to a nearby label can be practical for skipping the rest of one iteration. Long jumps and many labels make code harder to follow, so prefer straightforward If logic when it expresses the rule clearly.

Can I skip an item in a For Each loop?
Yes. Put the item-specific work inside an If condition, or jump to a label immediately before that loop’s Next. If you are also removing items from the collection, account for how removals affect iteration.

Related

Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.

More in VBA & macros

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.