Jump to the next count in a FOR Loop
Hi Tom,
You are right about GoTo being difficult interpretations and flow wise.
I just wanted to be aware of the contents of Tool-Box as much as possible.
Sometimes when Im stuck in middle of something (compilation or run-time
problem) then using a bad solution (Go To) for temporary period of time
seems to be a way out of dead-end. What I do is to add a comment and when I
get time I post the question on NG .
For example, the problem I had yesterday with Match and Iserror function...
I was trying somehow to solve the problem, but both the approaches were
blanking out. So for that moment I would have been happier even if i could
have got Iserror working, so that it would have got me working temporarily.
Oh.. yes ..In the morning when I saw your solution, I chose variant data
type rather than Exit Sub!!
Thanks a lot,
Hari
India
"Tom Ogilvy" wrote in message
...
Generally, if you examine the logic of your task, your code can fit into
the
IF ... Then or Case construct.
Using GoTo makes your code much more difficult to read - go back and look
at
some complex code you haven't looked at in a month or two and see if you
can
easily understand your logic. This it the advantage of
a) using structured programming
b) documenting your code.
c) coding in blocks and using subroutines and functions
There may be cases where a goto or exit is necessary, but you should
employ
them minimally and not as standard practice.
Perhaps your response it that the code is only for you, but you seem to
post
a lot of it up here and want people to understand it.
--
Regards,
Tom Ogilvy
"Hari Prasadh" wrote in message
...
Hi Bernie,
Thnx a lot. Would use it for my purpose.
Your method of Skipout reminds me of On Error go to ...method, which I
learned recently.
Thanks a lot,
Hari
India
"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Hari,
Maybe something like:
For i = 1 To Alot
If Something Then GoTo SkipOut
'code here
If SomethingElse Then GoTo SkipOut
'or code here
If Not StillSomethingElse Then GoTo SkipOut
'other code here
SkipOut:
Next i
HTH,
Bernie
MS Excel MVP
|