Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
can nay one help as 2 what a while and for a for loop does in vba?
and what are the syntaxes for these? also could any1 demonstrate how this would work in a section of code becasue there are so many types of loops and im gettinmg confused please help |
#2
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
There are basically 3
A Do While does while something is true as in Do While myValue=True stuff Loop it will do the code (stuff) until something changes myValue to False There is a Do Until which is kind of the opposite Do Until myValue=False stuff Loop This is the one I use most often, do something until cells are blank is most common and For Next is for when you know how many times to do something For i = 1 To sheets.count stuff Next This is one used often as well, the one above sets a base of 1 and does something for however many sheets there are. Handy because you can step forward backward 2 at a time etc. All really depends on your situation but you can almost always pick any of the 3 and make it suit your needs. -- -John Please rate when your question is answered to help us and others know what is helpful. "harry buggy" wrote: can nay one help as 2 what a while and for a for loop does in vba? and what are the syntaxes for these? also could any1 demonstrate how this would work in a section of code becasue there are so many types of loops and im gettinmg confused please help |
#3
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Just for completeness sake, there are two other loop formats..
Do Stuff Loop While <<logical test and Do Stuff Loop Until <<logical test The difference between these forms and their Do While/Until counterparts is that the Loop While/Until versions will always execute the Stuff statements at least one time because the exit condition isn't tested until the end of the loop. Rick "John Bundy" (remove) wrote in message ... There are basically 3 A Do While does while something is true as in Do While myValue=True stuff Loop it will do the code (stuff) until something changes myValue to False There is a Do Until which is kind of the opposite Do Until myValue=False stuff Loop This is the one I use most often, do something until cells are blank is most common and For Next is for when you know how many times to do something For i = 1 To sheets.count stuff Next This is one used often as well, the one above sets a base of 1 and does something for however many sheets there are. Handy because you can step forward backward 2 at a time etc. All really depends on your situation but you can almost always pick any of the 3 and make it suit your needs. -- -John Please rate when your question is answered to help us and others know what is helpful. "harry buggy" wrote: can nay one help as 2 what a while and for a for loop does in vba? and what are the syntaxes for these? also could any1 demonstrate how this would work in a section of code becasue there are so many types of loops and im gettinmg confused please help |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Loops | Excel Discussion (Misc queries) | |||
Loops... | Excel Discussion (Misc queries) | |||
do loops | Excel Worksheet Functions | |||
For next loops | Excel Discussion (Misc queries) | |||
Using For - Next Loops in VB | New Users to Excel |