Problem to skip loop

Hi,
I want to skip the loop below, per relevant conditions are matched
    Do While True
        ...

            If Trim(Worksheets(List0).Cells(RowID, 8).Value) <> "" And InStr(User_List, ";" & Trim(Worksheets(List0).Cells(RowID, 8).Value)) = 0 Then Continue Do
            End If

Open in new window

but I get 'Syntax Error' due to 'Continue Do'. What to adjust?
LVL 11
HuaMin ChenSystem AnalystAsked:
Who is Participating?
 
Saqib Husain, SyedConnect With a Mentor EngineerCommented:
Using your syntax

Since you also have an "End If" then there should be nothing after the "Then" in the same line. It should go to the next line.
If you put no code after "Then" it will automatically continue with the do loop. You do not have to tell it to do so.
The "Else" is to handle the other condition not satisfied by the if.

    Do While True
        ...

            If Trim(Worksheets(List0).Cells(RowID, 8).Value) <> "" And InStr(User_List, ";" & Trim(Worksheets(List0).Cells(RowID, 8).Value)) = 0 Then 

            else
                    do what you want to do otherwise
            End If

Open in new window

0
 
Saqib Husain, SyedEngineerCommented:
Exit do is used to skip loop

do while condition
     if certain condition then
             exit do
     endif
loop
0
 
GrahamSkanRetiredCommented:
If you want to leave the Do loop then use Exit Do
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
HuaMin ChenSystem AnalystAuthor Commented:
No, I only want to skip one iteration, and not to leave the whole loop.
0
 
Rob HensonConnect With a Mentor Finance AnalystCommented:
In which case just have an If statement within your Do Loop:

Do
  If Condition Then
    Code 1
  Else
    Code 2
  End If
Loop

Alternatively you could use the Select Case format within the Do Loop.
0
 
Saqib Husain, SyedEngineerCommented:
Looks like you are not fully satisfied with the answer.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.