Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If I am in a while or for loop and I have a statement like this:
if 1=1 then 'Go to next iteration of for loop or change cells and go back to top of while loop end if What is the syntax for continuing the loop at this point. Right now, I create spaghetti code by saying to goto a label like Goto NextLoop and then at the bottom of the loop right before the next or loop line, I have a line: NextLoop: But I want to avoid all this goto jumping. How do I do this? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Provide details of BOTH what you want to do and the full code you have
tried. -- Don Guillett Microsoft MVP Excel SalesAid Software "Mike H." wrote in message ... If I am in a while or for loop and I have a statement like this: if 1=1 then 'Go to next iteration of for loop or change cells and go back to top of while loop end if What is the syntax for continuing the loop at this point. Right now, I create spaghetti code by saying to goto a label like Goto NextLoop and then at the bottom of the loop right before the next or loop line, I have a line: NextLoop: But I want to avoid all this goto jumping. How do I do this? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here is an example of a While Loop
Do While True Line Input #ff, Line If Line Like "*rofit Center Totals:*" Then GoTo OutofLoop End If If Len(Line) = 0 Then GoTo MoreLoop ElseIf Line Like "*lass Name(ID):*" Then GoTo MoreLoop end if 'additional code here if the above jumps did not jump me somewhere MoreLoop: Loop OutofLoop: |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Do While True
Line Input #ff, Line If Line Like "*rofit Center Totals:*" Then Exit Do End If If Not Len(Line) = 0 Then If Not Line Like "*lass Name(ID):*" Then 'additional code here End If End If Loop -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Mike H." wrote in message ... Here is an example of a While Loop Do While True Line Input #ff, Line If Line Like "*rofit Center Totals:*" Then GoTo OutofLoop End If If Len(Line) = 0 Then GoTo MoreLoop ElseIf Line Like "*lass Name(ID):*" Then GoTo MoreLoop end if 'additional code here if the above jumps did not jump me somewhere MoreLoop: Loop OutofLoop: |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
That is what I was looking for:
Exit Do Is there also: Exit For? Thanks... |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
There is.
-- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Mike H." wrote in message ... That is what I was looking for: Exit Do Is there also: Exit For? Thanks... |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I was having trouble with Boorlean if not... stuff before and thought maybe
it wasn't available in this language either. But I'll have to make sure i write it correctly then use it. Thanks. |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Is there any syntax like
continue for that would perform another iteration of the loop? Sometimes it is not always practical to have the if...then... to cause the loop to run or not. |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Why not? You can always wrap that code into a procedure and call that.
-- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Mike H." wrote in message ... Is there any syntax like continue for that would perform another iteration of the loop? Sometimes it is not always practical to have the if...then... to cause the loop to run or not. |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Do While True
Line Input #ff, Line May not apply here, but using EOF was commonly used back in the dark ages: Do While Not EOF(1) Line Input #1, x ' etc... Loop -- HTH Dana DeLouis "Mike H." wrote in message ... Here is an example of a While Loop Do While True Line Input #ff, Line If Line Like "*rofit Center Totals:*" Then GoTo OutofLoop End If If Len(Line) = 0 Then GoTo MoreLoop ElseIf Line Like "*lass Name(ID):*" Then GoTo MoreLoop end if 'additional code here if the above jumps did not jump me somewhere MoreLoop: Loop OutofLoop: |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Rather than use a go add an if
Do while if condition then end if loop "Mike H." wrote: If I am in a while or for loop and I have a statement like this: if 1=1 then 'Go to next iteration of for loop or change cells and go back to top of while loop end if What is the syntax for continuing the loop at this point. Right now, I create spaghetti code by saying to goto a label like Goto NextLoop and then at the bottom of the loop right before the next or loop line, I have a line: NextLoop: But I want to avoid all this goto jumping. How do I do this? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Naming Worksheets - Loop within a loop issue | Excel Programming | |||
Naming Worksheets - Loop within a loop issue | Excel Programming | |||
(Complex) Loop within loop to create worksheets | Excel Programming | |||
Advancing outer Loop Based on criteria of inner loop | Excel Programming | |||
Problem adding charts using Do-Loop Until loop | Excel Programming |