Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Is there a VBA flow control statement that will ...
Is there a VBA statement that will caus a loop to immediately do the next
iteration? For example: sub x() ..... For i=strt To stp if not isnumeric(cells(i,j)) then goto Lbl ... ... Lbl: Next i I would like to avoid the goto and say: if not isnumeric(cells(i,j)) then NextIteration Thanks for any help |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Is there a VBA flow control statement that will ...
Why not just use your if/then/else statement.
For i=strt To stp if not isnumeric(cells(i,j)) then 'do nothing else 'do lots of things end if next i wrote: Is there a VBA statement that will caus a loop to immediately do the next iteration? For example: sub x() ..... For i=strt To stp if not isnumeric(cells(i,j)) then goto Lbl ... ... Lbl: Next i I would like to avoid the goto and say: if not isnumeric(cells(i,j)) then NextIteration Thanks for any help -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Is there a VBA flow control statement that will ...
"Dave Peterson" wrote:
Why not just use your if/then/else statement. For i=strt To stp if not isnumeric(cells(i,j)) then 'do nothing else 'do lots of things end if next i Because Real Programs can sometimes (often!) get unduly messy with nested "if" statements if you are limited to a goto-less programming style. Even Dijkstra admitted this in a public retraction of his (in)famous "GoTos Are Dangerous" diatribe. To encourage "acceptable" use of "goto", designers of modern programming languages added "structured gotos" like "continue" and "break" to go to the end of a loop or to exit a loop respectively. They also provide "return" to exit a function in the middle. I am not very familiar with VBA. VBA does appear to have Exit For, Exit Do, Exit Function and Exit Sub. But I do not see any structured statement for continuing a loop from the middle, other that goto a label at the end of the loop. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Is there a VBA flow control statement that will ...
I wrote:
I am not very familiar with VBA. VBA does appear to have Exit For, Exit Do, Exit Function and Exit Sub. But I do not see any structured statement for continuing a loop from the middle, other that goto a label at the end of the loop. I meant to add that I am surprised that "if ... then next" or "if ... then next i" does not function as "continue" because I thought that the specification of some forms of the BASIC language does, in fact, permit that. Admittedly, it has been many years (decades!) since I was involved with the BASIC language for other platforms. So my recollection could be wrong. |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Is there a VBA flow control statement that will ...
I would like to avoid the complexity of deelpy nested ifs that is sometimes
required. A jump directly to the end of the loop (without using a label) would be preferred. Many languages have such a statement (such as c's break statement). I am simply asking if VBA does. On Sat, 18 Mar 2006 18:25:40 -0600, Dave Peterson wrote: Why not just use your if/then/else statement. For i=strt To stp if not isnumeric(cells(i,j)) then 'do nothing else 'do lots of things end if next i wrote: Is there a VBA statement that will caus a loop to immediately do the next iteration? For example: sub x() ..... For i=strt To stp if not isnumeric(cells(i,j)) then goto Lbl ... ... Lbl: Next i I would like to avoid the goto and say: if not isnumeric(cells(i,j)) then NextIteration Thanks for any help |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Is there a VBA flow control statement that will ...
|
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Is there a VBA flow control statement that will ...
Thanks for the replies. As others pointed out, there are several ways to
accomplish the same thing, there just not as neat. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro for Cash flow Statement | Excel Discussion (Misc queries) | |||
How to create a macro to control data flow | Excel Discussion (Misc queries) | |||
set up a statement of cash flow template for operation activities | Excel Worksheet Functions | |||
Flow of control from UserForm to Sheet1 sub | Excel Programming | |||
Flow of control in VBA Question - Userform Interaction | Excel Programming |