what is the "continue" statement for VBA

yeekhoon

New Member
Joined
May 9, 2003
Messages
44
Hi

does anyone know what this the continue statement for VBA? A continue statement is used to end the current loop iteration and return control to the loop statement.

Thanks

Regards
Yee KHoon
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Are you asking a question ? OR you are looking forward for a confirmation of the answer to your question ?
 
Upvote 0
i'm looking for the keyword for continue statement in VBA. In java, there is continue keyword. but i'm not sure whether VBA have or not. i need to use the continue keyword to interate my looping


Are you asking a question ? OR you are looking forward for a confirmation of the answer to your question ?
 
Upvote 0
Ok, so your question is proper as you wanna know the syntax that can be replaced for the iteration in your program.

A friendly suggestion mate...dont complicate yourself comparing Java with VBA...you bet this is way too different in terms of syntax and logic as well...I am a JCP but here I am so a learner in VBA and I do follow a primary principle "never to compare java syntax with VBA" else you wud mess with your Java funda as well !
 
Upvote 0
Hi Stormseed,
Thanks for your golden advise. I thinking to explore further as i'm not sure whether the VBA have the syntax/keywords. if wud be good if there is such syntax.. right...

thanks

Regards
Yee Khoon

A friendly suggestion mate...dont complicate yourself comparing Java with VBA...you bet this is way too different in terms of syntax and logic as well...I am a JCP but here I am so a learner in VBA and I do follow a primary principle "never to compare java syntax with VBA" else you wud mess with your Java funda as well !
 
Upvote 0
Yee Khon

What exactly are you trying to do?

As far as I'm aware there is no equivalent of Continue in VBA.

But there are probably other methods to achieve what you want.
 
Upvote 0
Hi Norie,
Again, thanks for replying my post...
oh yeah... now i thinking to use the Goto syntax to achieve in my loop.

what i'm exectly want to do is that

Code:
for i = 0 to ubound(dataArray)

    if left(dataArray(i,3), 1) ="z" then continue
    
    
   cells(i,1).value = dataArray(i,1)

next i

Yee Khon

What exactly are you trying to do?

As far as I'm aware there is no equivalent of Continue in VBA.

But there are probably other methods to achieve what you want.
 
Upvote 0
Yee Khon

I'm sorry but it still isn't clear what you want to do.:)

If you want to exit the for loop based then use Exit For.
 
Upvote 0
Hi Yee

As you may well know, the use of GoTo is usually considered non structured programming.

There are 4 usual GoTo variations, the GoTo itsef and its pals Break (Exit in vba), Continue (no equivalent in vba) and Return (also Return in vba). Any of the 4 may break the flow of the program (used inside a loop may even break the logic of the loop) and so, according to the supporters of structured programming, should simply be avoided as much as possible (some will go as far as supporting the removal of this statement from the languages). You can find lots of information about structured programming on the Web and in programming / computer science books.

So, your:
Code:
For/Do/While
    ' code'
    If Condition then Continue
    ' more code'
End For/Loop
is equivalent to the also not structured:
Code:
For/Do/While
    ' code'
    If Condition then GoTo EndLoop
    ' more code'
EndLoop:
End For/Loop
or, to the classical structured
Code:
For/Do/While
    ' code'
    If Not Condition then 
        ' more code'
    End If
End For/Loop

Remark: I'm just contributing with information, I'm not saying that you should never use these statements. In some cases they may be useful and in others, for example if you use a switch construct in C/C++, unavoidable.

Hope this helps
PGC
 
Upvote 0

Forum statistics

Threads
1,223,641
Messages
6,173,506
Members
452,518
Latest member
SoerenB

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top