Unlock array when using For Each statement, no algebra!

Posted on 2006-04-06
Last Modified: 2010-04-07

I have a script something like this (the real script has alot of nested for-next statements, so no answers with counters please!):

For each DataItem in DataArray

    SplitData = Split(DataItem, ",")
    For Each SplitItem In SplitData
        If SplitItem = "Bad Condition" Then
            GoTo SkipBackCondition
        End If
    Next SplitItem

Next DataItem

If the script encounters the 'Bad Condition' it  tries to skip out of the For-Next, but the array SplitData is still locked by it, I need an 'End Next' statement or something? any ideas? I know I could use For i = 0 to ubound(SplitData) etc... and I will if I have to, but I would rather not use algebra counters if I there is a better way.

Question by:bhermer
    LVL 13

    Accepted Solution

    Try Exit For instead of GoTo SkipBackCondition
    LVL 4

    Author Comment

    That was easy, cheers!

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
    I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now