continue for in for loop RRS feed

  • Question

  • I am using a For Each In...Next loop to test a long range of cells, many of which are empty. I want the loop to skip to the next cell when it finds an empty one.

    The online reference for VB (not VBA) shows a "Continue For" statement that can be used to jump to the next iteration of the loop. I cannot get that to work in VBA in Excel 2010.

    Right now, here is what I can get to work:

    For Each aCell In WeeklyReport

        If aCell.Value = "" then

            GoTo WRLabel

        End If

        <Test the cells containing data>


    Next aCell

    I know the GoTo is kludgey. But when I replace it with "Continue For," I get an "expression expected" comiler error.

    What are my options? I know I could add an "Else" to the If statement and and put most of the loop there, but that would be harder to read.


    Monday, August 13, 2012 10:38 PM


All replies