Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
"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
Posted to microsoft.public.excel.programming
|
|||
|
|||
"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
Posted to microsoft.public.excel.programming
|
|||
|
|||
"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
Posted to microsoft.public.excel.programming
|
|||
|
|||
"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
Posted to microsoft.public.excel.programming
|
|||
|
|||
"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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
"X" at upper right of window to exit program is grayed out. | Excel Discussion (Misc queries) | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
Change default in input box from "20" to "000000"? Have macro continue on to name sheet tab? | Excel Programming | |||
Deleted the pivot table - continue to get the "overlap" error message | Excel Discussion (Misc queries) | |||
Automatically click "Update Links" & "Continue" | Excel Programming |