Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I have For I = 1 to 67 If ..... then 'Here I would like to go to the next Count in I and skip the execution of code till -- Next I -- End if '..... ' Some code 'Some code '.... '... Next I Please tell me what I should put inside the If statement so that I could accomplish the above. I cannot use -- Exit For -- as I dont want to stop the executon of loop abruptly. Thanks a lot, Hari India |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Hari
One way: For I = 1 to 67 If ..... then 'Here I would like to go to the next Count in I and skip the execution of code till -- Next I -- Else '..... ' Some code 'Some code '.... '... End if Next I -- Best Regards Leo Heuser Followup to newsgroup only please. "Hari Prasadh" skrev i en meddelelse ... Hi, I have For I = 1 to 67 If ..... then 'Here I would like to go to the next Count in I and skip the execution of code till -- Next I -- End if '..... ' Some code 'Some code '.... '... Next I Please tell me what I should put inside the If statement so that I could accomplish the above. I cannot use -- Exit For -- as I dont want to stop the executon of loop abruptly. Thanks a lot, Hari India |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Leo,
Im sorry, I should have mentioned this in my original post. Actually what u suggested Im already using. It's just that I wanted to know about other ways of dealing with it. Especially what happens if I have many instances of -- 'Here I would like to go to the next Count in I and skip the execution of code till ...-- within a single very big For Loop. Managing such a If else End If, becomes a little difficult. (Especially in the case when conditions are mutually exclusive) Thanks a lot, Hari India |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 "Hari Prasadh" wrote in message ... Hi Leo, Im sorry, I should have mentioned this in my original post. Actually what u suggested Im already using. It's just that I wanted to know about other ways of dealing with it. Especially what happens if I have many instances of -- 'Here I would like to go to the next Count in I and skip the execution of code till ...-- within a single very big For Loop. Managing such a If else End If, becomes a little difficult. (Especially in the case when conditions are mutually exclusive) Thanks a lot, Hari India |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How about
Select Case 'your test' Case 'value1' : 'do nothing Case 'value2' : ' do nothing 'etc. Case Else: myMacro End Select where myMacro includes your code. You can easily add extra conditions. -- HTH RP (remove nothere from the email address if mailing direct) "Hari Prasadh" wrote in message ... Hi Leo, Im sorry, I should have mentioned this in my original post. Actually what u suggested Im already using. It's just that I wanted to know about other ways of dealing with it. Especially what happens if I have many instances of -- 'Here I would like to go to the next Count in I and skip the execution of code till ...-- within a single very big For Loop. Managing such a If else End If, becomes a little difficult. (Especially in the case when conditions are mutually exclusive) Thanks a lot, Hari India |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
For i = 1 to 67
if not condition then ' some code ' some code end if Next -- Regards, Tom Ogilvy "Hari Prasadh" wrote in message ... Hi, I have For I = 1 to 67 If ..... then 'Here I would like to go to the next Count in I and skip the execution of code till -- Next I -- End if '..... ' Some code 'Some code '.... '... Next I Please tell me what I should put inside the If statement so that I could accomplish the above. I cannot use -- Exit For -- as I dont want to stop the executon of loop abruptly. Thanks a lot, Hari India |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
count rownumbers in loop | Excel Discussion (Misc queries) | |||
loop count | Excel Discussion (Misc queries) | |||
Jump out of Do Loop on sheet change | Excel Programming | |||
End loop macro with count | Excel Programming |