Excel VBA For Loop: Skip to the Next Iteration

VBA & macros · Updated November 21, 2026

Excel VBA does not have a built-in Continue For statement. To skip the rest of the current iteration and let the loop advance normally, put the remaining work inside an If block, or jump with GoTo to a label immediately before the loop’s Next statement.

Use the conditional approach when it keeps the code clear; use the label approach when several conditions should skip the same iteration. Do not use Exit For for this purpose: it ends the entire loop.

What “skip to next” means in VBA

A For...Next loop runs its body once for each counter value. When VBA reaches Next, it updates the counter and checks whether another iteration should run. “Skip to the next” means stop processing the current counter value, then continue at that normal loop progression point.

For example, a loop over worksheet rows might ignore blank cells and process the remaining rows. The skipped row is not revisited, and the loop still continues with the next row. This differs from stopping the loop altogether, which is what Exit For does.

Why there is no Continue For statement

Some programming languages provide a dedicated continue statement. VBA does not provide Continue For or Continue Do in its standard loop syntax. Typing Continue For into ordinary Excel VBA code therefore produces a compile error.

The usual workaround is to write the loop so that the work only happens when the item passes a condition. If the logic is more convenient as an early skip, a GoTo statement can jump to a label before Next. Both approaches leave loop control with VBA, which then advances the counter as usual.

Preferred approach: put the work inside an If block

When there is one simple rule for deciding whether to process an item, an If block is often easiest to read. The loop still visits every row, but the processing statements run only when the condition is true.

Sub ProcessPositiveNumbers()
    Dim i As Long
    Dim value As Variant

    For i = 2 To 20
        value = Cells(i, 1).Value2

        If IsNumeric(value) Then
            If CDbl(value) > 0 Then
                Cells(i, 2).Value = CDbl(value) * 2
            End If
        End If
    Next i
End Sub

This example reads values from column A, rows 2 through 20. If a value is numeric and greater than zero, it writes twice that value to the corresponding row in column B. Empty cells and text do not meet the test, so they are left alone. The loop itself continues through every row.

The nested conditions are deliberate: the code checks that a value is numeric before converting it with CDbl. For more complex rules, you can combine tests with And or use additional nested If blocks. In VBA, do not rely on And to protect a conversion or operation that may fail: VBA does not short-circuit the two sides of an And expression.

Use GoTo to skip several statements

If an item should be skipped as soon as any of several tests fails, a label immediately before Next can avoid wrapping a large block in multiple conditions. The label name is chosen by the programmer; it must end with a colon and be unique within the procedure.

Sub CopyValidNumbers()
    Dim i As Long
    Dim value As Variant

    For i = 2 To 100
        value = Cells(i, 1).Value2

        If IsError(value) Then GoTo NextRow
        If IsEmpty(value) Then GoTo NextRow
        If Not IsNumeric(value) Then GoTo NextRow

        Cells(i, 2).Value = CDbl(value)

NextRow:
    Next i
End Sub

Here, error values, empty cells, and nonnumeric values all jump to NextRow. VBA then reaches Next i, increments i, and starts the next iteration. The error check comes first because a worksheet error is a special Variant value, not an ordinary number or text value.

Keep the label inside the same procedure and close to the loop’s Next. A label placed far away can make control flow hard to follow. Also avoid jumping into the middle of a structured block such as an If or With block; put the skip label after the work to be bypassed, in a straightforward location.

Skipping items in a For Each loop

The same patterns work with For Each. The loop variable takes each object or value in the collection, and Next moves to the next one. In this example, blank or error cells are ignored and valid numeric cells are copied into column B.

Sub CopyNumericCells()
    Dim cell As Range

    For Each cell In Range("A2:A100")
        If IsError(cell.Value2) Then GoTo NextCell
        If IsEmpty(cell.Value2) Then GoTo NextCell
        If Not IsNumeric(cell.Value2) Then GoTo NextCell

        cell.Offset(0, 1).Value = CDbl(cell.Value2)

NextCell:
    Next cell
End Sub

Offset(0, 1) refers to the cell one column to the right on the same row. In real workbooks, qualify Range with a worksheet, such as ThisWorkbook.Worksheets("Data").Range("A2:A100"), so the macro does not depend on whichever sheet happens to be active. If you use that longer expression, declare a Worksheet variable or qualify the range directly.

Choose the right condition for the data

The correct skip test depends on what counts as an item worth processing. Blank cells, formula results that display as blank, worksheet errors, text, and zero are not interchangeable cases.

  • Truly empty cell: IsEmpty(value) detects an Empty Variant, as returned by a genuinely empty cell’s Value2.
  • Formula returning an empty string: this is not the same as an empty cell. Check Len(value) = 0 when the value is a string and that is the behavior you want.
  • Worksheet error: use IsError(value) before attempting numeric conversion or comparisons.
  • Text or other nonnumeric data: IsNumeric(value) can help, but decide whether numeric-looking text should count as a number for your task.
  • Zero or negative values: test these explicitly, for example with value <= 0, if they should be skipped. Zero is numeric, not blank.

Be precise about the desired rule. For example, “skip cells with no value” is different from “skip cells that look blank,” because a formula such as =IF(A1="","",A1) can return an empty string while the cell still contains a formula.

Nested loops and Exit For

In nested loops, a skip label should belong to the loop whose current iteration you intend to bypass. A label just before the inner loop’s Next skips the rest of that inner iteration; it does not skip the outer iteration. Use distinct labels such as NextColumn and NextRow so the destination is obvious.

Exit For has a different purpose: it leaves the nearest active For loop immediately. In a nested loop, that usually means the inner loop, after which execution continues with the outer loop. Use it when the search is finished or there is no reason to continue that loop—not merely because one item should be ignored.

For example, if you search a row for a matching value, you might use Exit For after finding the match. If a cell is empty but later cells still need checking, skip its processing and allow the loop to reach Next.

Common mistakes and debugging checks

  • Using Exit For to skip one item: this stops the loop instead of moving to its next iteration.
  • Putting the label after Next: jumping there bypasses the loop’s normal counter update. Put the label before the appropriate Next.
  • Using a label that is ambiguous: name it for its destination, especially when loops are nested.
  • Assuming every blank-looking cell is Empty: formulas returning "" are not truly empty.
  • Converting before checking: a blank, text value, or worksheet error may make a conversion or comparison fail. Validate the value first.
  • Forgetting the loop variable type: use Long for row counters; Excel worksheets can have more rows than fit in an Integer.

To debug, put the cursor in the procedure and use the Visual Basic Editor’s step-through controls to observe the counter and the branch taken. You can also inspect the value in the Locals window or hover over a variable while execution is paused. If the macro appears to skip too much, check the condition and confirm that the label is immediately before the intended loop’s Next.

Running VBA safely in Excel

These examples are written for desktop Excel for Microsoft 365 on Windows. Excel for the web cannot create, run, or edit VBA macros; open the workbook in desktop Excel to use them. Excel for Mac also supports VBA, although some Windows-specific automation, such as code that depends on Windows APIs or particular COM components, may need changes.

To run a macro, save the workbook in a macro-enabled format such as .xlsm, then run it from the VBA editor or Excel’s macro tools. Save a separate copy of the workbook before running a macro that changes cells: macro actions cannot be undone with Ctrl+Z. This matters even for a short loop, because a mistaken range or condition can alter many cells in one run.

When you test, use a small range that includes representative cases: a positive number, zero, a negative number, text, an empty cell, a formula returning an empty string, and an error value if the real data can contain one. Confirm both the cells that should change and the cells that should remain untouched before expanding the range.

Frequently Asked Questions

Can I use Continue For in Excel VBA?
No. Standard Excel VBA does not support a Continue For statement. Put the processing inside an If condition, or use a GoTo label immediately before the loop’s Next.

Does GoTo Next skip the loop counter increment?
It depends on where the destination is. A jump to a label just before Next still reaches Next, so the counter advances normally. A jump that goes past Next can bypass that normal progression and is generally the wrong pattern for skipping one iteration.

What is the difference between Next and Exit For?
Next completes the current iteration and advances the loop. Exit For leaves the current For loop immediately, so remaining iterations are not run.

Can I skip to the next item in For Each?
Yes. Use a condition to omit the work for an item, or jump to a label immediately before Next item. VBA then retrieves the next item in the collection.

How do I skip blank cells but keep processing the range?
Test the cell’s value and run the processing code only when it is not blank. For a truly empty cell, IsEmpty(cell.Value2) is useful. If formulas can return an empty string, test for that separately because such a cell is not truly empty.

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.