Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default "Continue" and Exit with For Loops

Most of my recent scripting has been with Javascript (for Photoshop). With
For Loops I am missing the ability to use a 'continue' command which skips to
the next iteration of the for loop. I can achieve the same with IF statements
but sometimes, when one is already within a series of nested IF statements,
this becomes rather cumbersome. I suspect I can also achieve it with
functions and / or subroutines but again that looks a messy to me. I guess I
could use Go To the first line inside the loop, while resetting the counter
(though that won't work in For Each).

How do the pro's do it in VBA?

One other question while I am at it. One of the best methods for learning
Photoshop Javascript was to got to the Adobe Share Scripts site and download
scripts and look at them. Is there an equivalent for VBA you would recommend.

TIA

Andrew
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default "Continue" and Exit with For Loops

I realize I forgot to add another colosely related issue - exiting out of
nested For loops. I can do this using a boolean variable in the inner loop
that then is tested in the outer loop but is there a better way (perhaps GoTo
again)

Andrew
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default "Continue" and Exit with For Loops

Nested IFs is the way I do it, with breakouts to functions.

I suppose that you could add a single iteration For ... Next loop, and Exit
For within that, but seems kludgy to me.

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Andrew Hall NZ" wrote in message
...
Most of my recent scripting has been with Javascript (for Photoshop). With
For Loops I am missing the ability to use a 'continue' command which skips

to
the next iteration of the for loop. I can achieve the same with IF

statements
but sometimes, when one is already within a series of nested IF

statements,
this becomes rather cumbersome. I suspect I can also achieve it with
functions and / or subroutines but again that looks a messy to me. I guess

I
could use Go To the first line inside the loop, while resetting the

counter
(though that won't work in For Each).

How do the pro's do it in VBA?

One other question while I am at it. One of the best methods for learning
Photoshop Javascript was to got to the Adobe Share Scripts site and

download
scripts and look at them. Is there an equivalent for VBA you would

recommend.

TIA

Andrew



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default "Continue" and Exit with For Loops

'This structure assumes that for each object, many work blocks can be
processed on each object.

Dim bSkip as Boolean ' logic if true, then skip rest of for loop.
For Each obj1 in objects
bSkip = False
[Work block1
bSkip = true or false]
if bSkip Then Goto ForEndA
[Work block2
bSkip = true or false]
if bSkip Then Goto ForEndA
[Work block3
bSkip = true or false]
....
ForEndA:
last steps every object need do before next object.
Next

-Stephen Rasey



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default "Continue" and Exit with For Loops

Nice one Stephen, that's exactly what I was looking for and it's very general

Andrew
Reply
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
"X" at upper right of window to exit program is grayed out. Robert Excel Discussion (Misc queries) 3 September 2nd 08 10:48 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Change default in input box from "20" to "000000"? Have macro continue on to name sheet tab? StargateFanFromWork[_4_] Excel Programming 7 October 29th 06 11:46 AM
Deleted the pivot table - continue to get the "overlap" error message [email protected] Excel Discussion (Misc queries) 0 September 27th 06 04:07 PM
Automatically click "Update Links" & "Continue" paulharvey[_13_] Excel Programming 0 June 3rd 06 05:35 PM


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

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

About Us

"It's about Microsoft Excel"