Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Incrementing Do/Loop, For/Next and For/Each

I've got several loops where I discover midway through the loop that I don't
want to process the remaining commands before the "Loop" or "Next" at the
end of the loop. I DO NOT want to exit the loop -- just increment the
counter and process the next loop for next incremented variable.

I know that variables such as "i" in For i = 1 to 100 can be incremented
mid-loop, but this is not advisable.

Is there a way to skip to the bottom of a loop without using a GoTo
statement? Or is that the only way?

The Exit For command is no good because I want to continue processing the
remaining elements, not end the loop.

TIA
Steve

Sdrenker <is at pacbell <with a dot net

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Incrementing Do/Loop, For/Next and For/Each

Try a Do While loop

n = 1
Do While n < 100
n = n + 1
If something Then
n = NewValue
etc.
End If
Loop

"Steve Drenker" wrote:

I've got several loops where I discover midway through the loop that I don't
want to process the remaining commands before the "Loop" or "Next" at the
end of the loop. I DO NOT want to exit the loop -- just increment the
counter and process the next loop for next incremented variable.

I know that variables such as "i" in For i = 1 to 100 can be incremented
mid-loop, but this is not advisable.

Is there a way to skip to the bottom of a loop without using a GoTo
statement? Or is that the only way?

The Exit For command is no good because I want to continue processing the
remaining elements, not end the loop.

TIA
Steve

Sdrenker <is at pacbell <with a dot net


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Incrementing Do/Loop, For/Next and For/Each

Hi Steve,

Possibly, one way:

Dim blOk as Boolean

For i = 1 to 100

blOk = True
If ConditionTrue Then
'Do something
Else
BlOk =false
End If

'Processing code

If blOK then
'More processing
End if

Next i


---
Regards,
Norman



"Steve Drenker" wrote in message
...
I've got several loops where I discover midway through the loop that I
don't
want to process the remaining commands before the "Loop" or "Next" at the
end of the loop. I DO NOT want to exit the loop -- just increment the
counter and process the next loop for next incremented variable.

I know that variables such as "i" in For i = 1 to 100 can be incremented
mid-loop, but this is not advisable.

Is there a way to skip to the bottom of a loop without using a GoTo
statement? Or is that the only way?

The Exit For command is no good because I want to continue processing the
remaining elements, not end the loop.

TIA
Steve

Sdrenker <is at pacbell <with a dot net



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Incrementing Do/Loop, For/Next and For/Each

The usual aproach is to use an IF:

For i = 1 to 10
if (things are good) then
yada yada yada
Yada Yada yada
else
endif
next

This will actually skip to the end of the For, but allow it to keep iterating.
--
Gary's Student


"Steve Drenker" wrote:

I've got several loops where I discover midway through the loop that I don't
want to process the remaining commands before the "Loop" or "Next" at the
end of the loop. I DO NOT want to exit the loop -- just increment the
counter and process the next loop for next incremented variable.

I know that variables such as "i" in For i = 1 to 100 can be incremented
mid-loop, but this is not advisable.

Is there a way to skip to the bottom of a loop without using a GoTo
statement? Or is that the only way?

The Exit For command is no good because I want to continue processing the
remaining elements, not end the loop.

TIA
Steve

Sdrenker <is at pacbell <with a dot net


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Incrementing Do/Loop, For/Next and For/Each

just use an if...then block to wrap the code you might want to skip, and
test for the "skip" condition in that block.

--
Tim Williams
Palo Alto, CA


"Steve Drenker" wrote in message
...
I've got several loops where I discover midway through the loop that I

don't
want to process the remaining commands before the "Loop" or "Next" at the
end of the loop. I DO NOT want to exit the loop -- just increment the
counter and process the next loop for next incremented variable.

I know that variables such as "i" in For i = 1 to 100 can be incremented
mid-loop, but this is not advisable.

Is there a way to skip to the bottom of a loop without using a GoTo
statement? Or is that the only way?

The Exit For command is no good because I want to continue processing the
remaining elements, not end the loop.

TIA
Steve

Sdrenker <is at pacbell <with a dot net



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
Loop Until non-incrementing cell condition met. GBExcel via OfficeKB.com Excel Worksheet Functions 3 November 4th 09 07:47 PM
incrementing paul/bones[_2_] Excel Worksheet Functions 2 September 12th 07 01:54 PM
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 PM
incrementing columns in a loop Mitch Excel Programming 1 June 9th 05 03:40 PM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM


All times are GMT +1. The time now is 05:12 PM.

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"