VBA Loop Continue: How to Skip to the Next Iteration

VBA & macros · Updated November 2, 2026

VBA Loop Continue: How to Skip to the Next Iteration

VBA has no built-in Continue For, Continue Do, or general Continue statement. To skip the rest of the current loop pass, either put the work you want to skip inside an If block, or use GoTo to jump to a label immediately before the loop’s Next or Loop.

What “continue” means in a VBA loop

A continue statement, in languages that provide one, ends the current iteration and starts the next one. It does not end the whole loop. For example, a loop might inspect each worksheet row, ignore blank or invalid entries, and process only the rows that meet a condition.

VBA distinguishes that action from two statements it does support:

  • Exit For leaves a For or For Each loop altogether.
  • Exit Do leaves a Do loop altogether.
  • A continue-style pattern skips the remaining work for one pass and lets the loop proceed.

This distinction matters when writing an import, validation, or calculation macro. If one bad row should be ignored but later rows still need processing, an exit statement is not a substitute for continue.

Why VBA does not have a Continue statement

VBA is based on the Visual Basic language used for automating Office applications, and its loop syntax does not include the continue keywords found in some other programming languages. A line such as Continue For is therefore not valid VBA. Searching for a VBA setting that enables it will not help; the usual solution is to structure the loop differently or use a label and GoTo.

That does not mean every use of GoTo is good design. A short jump to the bottom of a loop can make a clear “skip this item” path, but many jumps in different directions make a procedure harder to follow. Prefer straightforward conditional logic when it stays readable.

Use an If block for the clearest pattern

For many loops, the simplest approach is to put the processing inside an If statement that tests whether the current item is eligible. When the test is false, VBA reaches the end of the loop body without doing the processing, then moves on normally. This achieves the practical effect of continue without a jump.

For example, suppose a macro reads values from column A and should add only positive numbers. It can test each value and add it only when it is numeric and greater than zero. If the cell is blank, contains text, or contains zero or a negative number, the addition is simply not performed. In a longer loop, place the whole block of work for eligible rows inside the condition.

Nested If statements can be useful when a value needs several checks, such as first checking for an Excel error and then checking whether the value is numeric. Keep the conditions in an order that avoids applying a conversion or calculation to a value that has not passed the necessary checks. This style is especially suitable when there are only one or two skip conditions.

Use GoTo for an explicit skip-to-next pattern

When a loop has several rejection checks near its top and a substantial body of work after them, a label immediately before Next can make each skip explicit. The following example reads column A on a worksheet named Data, skips errors, nonnumeric entries, and values at or below zero, and adds the remaining values. It assumes values are in A2 downward; if A2:A6 contain 12, -3, text, 8, and 0, the total written to B1 is 20.

Save a copy of the workbook before running a macro. VBA changes cannot be undone with Ctrl+Z.

Option Explicit

Sub SumPositiveValues()
    Dim ws As Worksheet
    Dim lastRow As Long
    Dim i As Long
    Dim total As Double
    Dim cellValue As Variant

    Set ws = ThisWorkbook.Worksheets("Data")
    lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row

    For i = 2 To lastRow
        cellValue = ws.Cells(i, "A").Value

        If IsError(cellValue) Then GoTo ContinueRow
        If Not IsNumeric(cellValue) Then GoTo ContinueRow
        If CDbl(cellValue) <= 0 Then GoTo ContinueRow

        total = total + CDbl(cellValue)

ContinueRow:
    Next i

    ws.Range("B1").Value = total
End Sub

The label is part of the procedure, and the jump lands at the end of the current loop body. VBA then executes Next i, which advances the counter and begins the next pass if the loop has not finished. The label must be unique within the procedure; if the procedure contains multiple loops, give each loop’s label a distinct name, such as ContinueRow and ContinueColumn.

Keep the label close to the loop’s ending statement. A jump to a distant label can make it unclear which statements are skipped, and a jump that bypasses necessary cleanup or counter updates can cause incorrect results or an endless loop.

For Each loops and Do loops

The same label pattern can be used with For Each. Put the label directly before the matching Next statement, and jump there when the current object should be ignored. For example, a macro processing a range might skip cells that are empty, then handle the remaining cells. Declare the range and cell variables with appropriate object types, such as Range, and make sure the skip path does not omit work required for later cells.

With a Do loop, a label can be placed immediately before Loop. However, pay close attention to loop control. In a counter-based Do While loop, the counter must still be updated on every path before the loop condition is checked again. Otherwise, skipping a row can leave the counter unchanged and repeat the same pass forever.

Often a Do loop is clearer when its counter update is written once at the bottom and the processing is conditional. That way, both eligible and skipped items reach the update. For loops that read until a cell or record signals the end, make sure every path either advances to the next item or deliberately exits the loop.

Handling nested loops and skip scope

In nested loops, decide exactly which loop should advance. A continue-style jump to the inner loop’s end skips the rest of that inner iteration and proceeds to its next item; it does not skip the remaining iterations of the outer loop. To skip the current outer item, the control flow must reach the outer loop’s ending point instead.

This is one reason conditional blocks are often safer in nested code. A condition around the inner-loop work can show clearly which level is affected. If labels are used, name them to identify the target loop and keep each one next to its corresponding Next or Loop. Do not reuse a label name in the same procedure, and avoid jumps that make it difficult to see which loop advances.

If nested logic becomes difficult to follow, consider moving a well-defined operation into a separate function or procedure that returns whether the item should be processed. Smaller procedures can make the skip rule easier to understand than adding more labels.

Continue versus Exit For and Exit Do

Choose the control statement based on what should happen after a condition is met. If only the current item should be ignored, use a conditional block or a loop-end label. If there is no reason to examine any more items, use Exit For or Exit Do. For example, a search can use Exit For once it has found the one result it needs, while a row-validation routine may need to skip a bad row and keep checking the rest.

A common mistake is to use Exit For as if it were continue. That stops the entire loop, so rows after the first rejected row are never examined. The reverse mistake is also possible: using a jump to the loop end when the condition means the whole search is over. Choose the behavior that matches the task, not just the shortest line of code.

Common problems and safer debugging

Most errors in continue-style VBA loops come from control flow rather than syntax. Check these points if a macro skips too much, repeats indefinitely, or fails to compile:

  • Confirm the label is spelled exactly the same in the GoTo statement and its definition, and that the label ends with a colon.
  • Make sure a label is unique within its procedure and is positioned immediately before the intended loop-ending statement.
  • For a Do loop controlled by a counter, verify the counter advances on every path that continues.
  • Check that a skip does not bypass required cleanup, such as closing a file or restoring an application setting.
  • Use Exit For or Exit Do only when the entire loop should stop.

When debugging, step through the procedure and watch the loop variable and the value being tested. In the Visual Basic Editor, pressing F8 steps through code one statement at a time on Windows. On Mac, the equivalent shortcut can depend on the keyboard and function-key settings; use the editor’s Step Into command if F8 is assigned to a system function. A breakpoint at the loop body can also help reveal whether a rejected item is reaching the expected next pass.

Frequently Asked Questions

Does VBA support Continue For?

No. Continue For is not a VBA statement. Put the work inside an If block or use GoTo to a label before the loop’s Next statement.

What is the VBA equivalent of continue?

There is no single built-in equivalent. Conditional logic is usually the simplest choice; a label at the end of the loop is a common explicit skip pattern when there are several early rejection checks.

Can I use GoTo to skip a For Each item?

Yes. Put a uniquely named label immediately before the matching Next statement and jump to it when the current item should be skipped. Keep the label close to that loop so the target is unambiguous.

Does Exit For skip only the current iteration?

No. Exit For leaves the loop entirely. Use a conditional block or a jump to the loop’s end when later items still need to be processed.

How do I skip an item in a Do While loop?

Use an If block to conditionally run the item’s processing, while ensuring the loop’s counter or other progress condition is updated on every pass. A label before Loop is another option, but it must not bypass that update.

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.