View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Is there a VBA flow control statement that will ...

If that "do lots of things" gets too messy, you could always replace it with a
call to a subroutine or a function.



wrote:

"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.


--

Dave Peterson