Unlock array when using For Each statement, no algebra!

Posted on 2006-04-06
Medium Priority
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

rettiseert earned 2000 total points
ID: 16393082
Try Exit For instead of GoTo SkipBackCondition

Author Comment

ID: 16394691
That was easy, cheers!

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month8 days, 7 hours left to enroll

615 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