LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Jump to the next count in a FOR Loop

Got to endorse Tom's wise words. IMO it is a weakness of VBA that we need
goto's for error handling, a throwback to older Basics I guess. I once
worked on a electoral roll application written in Cobol, a version of Cobol
that allowed alterable gotos. Can you imagine the nightmare of trying to
debug that.

Bob


"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







 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
count rownumbers in loop TUNGANA KURMA RAJU Excel Discussion (Misc queries) 9 October 3rd 05 09:29 AM
loop count TUNGANA KURMA RAJU Excel Discussion (Misc queries) 2 October 1st 05 04:54 AM
Jump out of Do Loop on sheet change Paul Excel Programming 2 May 14th 04 04:21 PM
End loop macro with count Jason C. Excel Programming 1 July 16th 03 01:21 PM


All times are GMT +1. The time now is 09:40 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"