Continue While

bklabel1

Board Regular
Joined
Feb 24, 2015
Messages
134
I noticed that there is not a Continue While or break in a While loop in VBA. What is the reason for NOT having it? Does Microsoft expect us to code in another way? Maybe use more function or sub calls? I can use GoTo s with labels but they are ugly.
 
Nested IF..End IF

VBA Code:
Do
    ' do stuff
    If rule-is-followed Then
        ' do more stuff
        If rule-is-followed Then
            ' do more
        End If
    End If
Loop Until Done.
 
Upvote 0

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Stay inside of the inner do. Break out as needed but remain inside of the outer loop. The inside one keeps spinning so it has a break at the end.
Is this something used in VBA?

Do
get next row of data
Do while (true)
IF this rule is broken, report it and Exit Do
IF this rule is broken, report it and Exit Do
IF this rule is broken, Exit Do
Always Exit Do here.
Loop until no more rows to examine in file
Loop
 
Upvote 0
My indentation was lost. I don't know how to edit a post so I will repost.

VBA Code:
Do
  get next row of data
  Do while (true)
      IF this rule is broken, report it and Exit Do
      IF this rule is broken, report it and Exit Do
      IF this rule is broken, Exit Do
      Always Exit Do here.
  Loop until no more rows to examine in file
Loop
 
Upvote 0

Forum statistics

Threads
1,216,028
Messages
6,128,399
Members
449,447
Latest member
M V Arun

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