Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default returning back to loop check condition without completing the loop

Hi All,

I apologise if this question has been posted before but to be true, I
could not find it.

I have a very little question. Please see below

Do While some_condition = TRUE

'-----Some Code----

If this_condition = TRUE then

' Here I would like to send the execution back to "Do
While some_condition = TRUE"
' and bypass all succeeding lines of code

End If

'-----Some Code----

loop

Kindly let me know if this is supported / possible in VBA.

Regards

Ashish
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default returning back to loop check condition without completing the loop

Do While some_condition = TRUE

'-----Some Code----

If this_condition = TRUE then
'do nothing
else
'some code here
End If

'no code here!!!!
loop

ashish128 wrote:

Hi All,

I apologise if this question has been posted before but to be true, I
could not find it.

I have a very little question. Please see below

Do While some_condition = TRUE

'-----Some Code----

If this_condition = TRUE then

' Here I would like to send the execution back to "Do
While some_condition = TRUE"
' and bypass all succeeding lines of code

End If

'-----Some Code----

loop

Kindly let me know if this is supported / possible in VBA.

Regards

Ashish


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default returning back to loop check condition without completing the loop

You could use a Label Statement and a GoTo statement like this...

Do While some_condition = TRUE
'-----Some Code----
If this_condition = TRUE then GoTo Continue
'-----Some Code----
Continue:
Loop


Rick


"ashish128" wrote in message
...
Hi All,

I apologise if this question has been posted before but to be true, I
could not find it.

I have a very little question. Please see below

Do While some_condition = TRUE

'-----Some Code----

If this_condition = TRUE then

' Here I would like to send the execution back to "Do
While some_condition = TRUE"
' and bypass all succeeding lines of code

End If

'-----Some Code----

loop

Kindly let me know if this is supported / possible in VBA.

Regards

Ashish


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default returning back to loop check condition without completing theloop

On Mar 18, 8:30*pm, Dave Peterson wrote:
Do While some_condition = TRUE

* * * '-----Some Code----

* * * *If this_condition = TRUE then
* * * * * *'do nothing
* * * *else
* * * * * *'some code here
* * * *End If

* * * *'no code here!!!!
loop





ashish128 wrote:

Hi All,


I apologise if this question has been posted before but to be true, I
could not find it.


I have a very little question. Please see below


Do While some_condition = TRUE


* * * '-----Some Code----


* * * *If this_condition = TRUE then


* * * * * * * ' Here I would like to send the execution back to "Do
While some_condition = TRUE"
* * * * * * * ' and bypass all succeeding lines of code


* * * *End If


* * * '-----Some Code----


loop


Kindly let me know if this is supported / possible in VBA.


Regards


Ashish


--

Dave Peterson- Hide quoted text -

- Show quoted text -


Hi Dave,

I know this will work but I cannot do this. I just want to stop
execution and return it to loop checking condition.
Besides this, I need to apply this at several places in my loop.

Thanks for your help
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default returning back to loop check condition without completing theloop

On Mar 18, 8:30*pm, Dave Peterson wrote:
Do While some_condition = TRUE

* * * '-----Some Code----

* * * *If this_condition = TRUE then
* * * * * *'do nothing
* * * *else
* * * * * *'some code here
* * * *End If

* * * *'no code here!!!!
loop





ashish128 wrote:

Hi All,


I apologise if this question has been posted before but to be true, I
could not find it.


I have a very little question. Please see below


Do While some_condition = TRUE


* * * '-----Some Code----


* * * *If this_condition = TRUE then


* * * * * * * ' Here I would like to send the execution back to "Do
While some_condition = TRUE"
* * * * * * * ' and bypass all succeeding lines of code


* * * *End If


* * * '-----Some Code----


loop


Kindly let me know if this is supported / possible in VBA.


Regards


Ashish


--

Dave Peterson- Hide quoted text -

- Show quoted text -


Dear Dave,

My question is to break the process flow in middle of a loop and
restart it from the loop condition checking.

Regards


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default returning back to loop check condition without completing the loop

You didn't like Rick's reply?

ashish128 wrote:

On Mar 18, 8:30 pm, Dave Peterson wrote:
Do While some_condition = TRUE

'-----Some Code----

If this_condition = TRUE then
'do nothing
else
'some code here
End If

'no code here!!!!
loop





ashish128 wrote:

Hi All,


I apologise if this question has been posted before but to be true, I
could not find it.


I have a very little question. Please see below


Do While some_condition = TRUE


'-----Some Code----


If this_condition = TRUE then


' Here I would like to send the execution back to "Do
While some_condition = TRUE"
' and bypass all succeeding lines of code


End If


'-----Some Code----


loop


Kindly let me know if this is supported / possible in VBA.


Regards


Ashish


--

Dave Peterson- Hide quoted text -

- Show quoted text -


Dear Dave,

My question is to break the process flow in middle of a loop and
restart it from the loop condition checking.

Regards


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default returning back to loop check condition without completing theloop

On Mar 24, 5:35*pm, Dave Peterson wrote:
You didn't like Rick's reply?





ashish128 wrote:

On Mar 18, 8:30 pm, Dave Peterson wrote:
Do While some_condition = TRUE


* * * '-----Some Code----


* * * *If this_condition = TRUE then
* * * * * *'do nothing
* * * *else
* * * * * *'some code here
* * * *End If


* * * *'no code here!!!!
loop


ashish128 wrote:


Hi All,


I apologise if this question has been posted before but to be true, I
could not find it.


I have a very little question. Please see below


Do While some_condition = TRUE


* * * '-----Some Code----


* * * *If this_condition = TRUE then


* * * * * * * ' Here I would like to send the execution back to "Do
While some_condition = TRUE"
* * * * * * * ' and bypass all succeeding lines of code


* * * *End If


* * * '-----Some Code----


loop


Kindly let me know if this is supported / possible in VBA.


Regards


Ashish


--


Dave Peterson- Hide quoted text -


- Show quoted text -


Dear Dave,


My question is to break the process flow in middle of a loop and
restart it from the loop condition checking.


Regards


--

Dave Peterson- Hide quoted text -

- Show quoted text -


Dear Dave,

I must say that there is some problem with the GUI.

My post says 6 messages but I cannot view more than 4 (two mine and
two of yours)

Therefore I dont even know if Rick has suggested some solution.

Please convey my apologies to Rick (If you can) as I cannot see a
single post of his.

Thank You.

Regards
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default returning back to loop check condition without completing the loop

Hoping that you will be able to see this response from me, here is what I
posted originally...

You could use a Label Statement and a GoTo statement like this...

Do While some_condition = TRUE
'-----Some Code----
If this_condition = TRUE then GoTo Continue
'-----Some Code----
Continue:
Loop

Please indicate if you can see this message.

If Ashish doesn't respond in a reasonable time period, will someone be kind
enough to copy and post it back to Ashish for me.

Rick



"ashish128" wrote in message
...
On Mar 24, 5:35 pm, Dave Peterson wrote:
You didn't like Rick's reply?





ashish128 wrote:

On Mar 18, 8:30 pm, Dave Peterson wrote:
Do While some_condition = TRUE


'-----Some Code----


If this_condition = TRUE then
'do nothing
else
'some code here
End If


'no code here!!!!
loop


ashish128 wrote:


Hi All,


I apologise if this question has been posted before but to be true,
I
could not find it.


I have a very little question. Please see below


Do While some_condition = TRUE


'-----Some Code----


If this_condition = TRUE then


' Here I would like to send the execution back to "Do
While some_condition = TRUE"
' and bypass all succeeding lines of code


End If


'-----Some Code----


loop


Kindly let me know if this is supported / possible in VBA.


Regards


Ashish


--


Dave Peterson- Hide quoted text -


- Show quoted text -


Dear Dave,


My question is to break the process flow in middle of a loop and
restart it from the loop condition checking.


Regards


--

Dave Peterson- Hide quoted text -

- Show quoted text -


Dear Dave,

I must say that there is some problem with the GUI.

My post says 6 messages but I cannot view more than 4 (two mine and
two of yours)

Therefore I dont even know if Rick has suggested some solution.

Please convey my apologies to Rick (If you can) as I cannot see a
single post of his.

Thank You.

Regards

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default returning back to loop check condition without completing theloop

On Mar 31, 12:59*pm, "Rick Rothstein \(MVP - VB\)"
wrote:
Hoping that you will be able to see this response from me, here is what I
posted originally...

You could use a Label Statement and a GoTo statement like this...

Do While some_condition = TRUE
* * '-----Some Code----
* * If this_condition = TRUE then GoTo Continue
* * '-----Some Code----
Continue:
Loop

Please indicate if you can see this message.

If Ashish doesn't respond in a reasonable time period, will someone be kind
enough to copy and post it back to Ashish for me.

Rick

"ashish128" wrote in message

...
On Mar 24, 5:35 pm, Dave Peterson wrote:





You didn't like Rick's reply?


ashish128 wrote:


On Mar 18, 8:30 pm, Dave Peterson wrote:
Do While some_condition = TRUE


'-----Some Code----


If this_condition = TRUE then
'do nothing
else
'some code here
End If


'no code here!!!!
loop


ashish128 wrote:


Hi All,


I apologise if this question has been posted before but to be true,
I
could not find it.


I have a very little question. Please see below


Do While some_condition = TRUE


'-----Some Code----


If this_condition = TRUE then


' Here I would like to send the execution back to "Do
While some_condition = TRUE"
' and bypass all succeeding lines of code


End If


'-----Some Code----


loop


Kindly let me know if this is supported / possible in VBA.


Regards


Ashish


--


Dave Peterson- Hide quoted text -


- Show quoted text -


Dear Dave,


My question is to break the process flow in middle of a loop and
restart it from the loop condition checking.


Regards


--


Dave Peterson- Hide quoted text -


- Show quoted text -


Dear Dave,

I must say that there is some problem with the GUI.

My post says 6 messages but I cannot view more than 4 (two mine and
two of yours)

Therefore I dont even know if Rick has suggested some solution.

Please convey my apologies to Rick (If you can) as I cannot see a
single post of his.

Thank You.

Regards- Hide quoted text -

- Show quoted text -


Dear Rick,

Yes, now I can see your post (But still my post says 8 Messages and I
am ble to see only 6).

Thanks for the suggestion. Being a programmer (in C Language) I was
taught not to use "Goto" as a primary rule.

But if you are suggesting this then there must be no ther way.

Thank you again for showing the way.

Regards
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default returning back to loop check condition without completing the loop

Why not use the "nested if" if you don't like GoTo's?

ashish128 wrote:

On Mar 31, 12:59 pm, "Rick Rothstein \(MVP - VB\)"
wrote:
Hoping that you will be able to see this response from me, here is what I
posted originally...

You could use a Label Statement and a GoTo statement like this...

Do While some_condition = TRUE
'-----Some Code----
If this_condition = TRUE then GoTo Continue
'-----Some Code----
Continue:
Loop

Please indicate if you can see this message.

If Ashish doesn't respond in a reasonable time period, will someone be kind
enough to copy and post it back to Ashish for me.

Rick

"ashish128" wrote in message

...
On Mar 24, 5:35 pm, Dave Peterson wrote:





You didn't like Rick's reply?


ashish128 wrote:


On Mar 18, 8:30 pm, Dave Peterson wrote:
Do While some_condition = TRUE


'-----Some Code----


If this_condition = TRUE then
'do nothing
else
'some code here
End If


'no code here!!!!
loop


ashish128 wrote:


Hi All,


I apologise if this question has been posted before but to be true,
I
could not find it.


I have a very little question. Please see below


Do While some_condition = TRUE


'-----Some Code----


If this_condition = TRUE then


' Here I would like to send the execution back to "Do
While some_condition = TRUE"
' and bypass all succeeding lines of code


End If


'-----Some Code----


loop


Kindly let me know if this is supported / possible in VBA.


Regards


Ashish


--


Dave Peterson- Hide quoted text -


- Show quoted text -


Dear Dave,


My question is to break the process flow in middle of a loop and
restart it from the loop condition checking.


Regards


--


Dave Peterson- Hide quoted text -


- Show quoted text -


Dear Dave,

I must say that there is some problem with the GUI.

My post says 6 messages but I cannot view more than 4 (two mine and
two of yours)

Therefore I dont even know if Rick has suggested some solution.

Please convey my apologies to Rick (If you can) as I cannot see a
single post of his.

Thank You.

Regards- Hide quoted text -

- Show quoted text -


Dear Rick,

Yes, now I can see your post (But still my post says 8 Messages and I
am ble to see only 6).

Thanks for the suggestion. Being a programmer (in C Language) I was
taught not to use "Goto" as a primary rule.

But if you are suggesting this then there must be no ther way.

Thank you again for showing the way.

Regards


--

Dave Peterson


  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default returning back to loop check condition without completing the loop

I apologise if this question has been posted before but to be true,
I could not find it. I have a very little question. Please see below

Do While some_condition = TRUE
'-----Some Code----
If this_condition = TRUE then
' Here I would like to send the execution back to "Do
While some_condition = TRUE"
' and bypass all succeeding lines of code
End If
'-----Some Code----
loop

Kindly let me know if this is supported / possible in VBA.


You could use a Label Statement and a GoTo statement like this...

Do While some_condition = TRUE
'-----Some Code----
If this_condition = TRUE then GoTo Continue
'-----Some Code----
Continue:
Loop


Dear Rick,

Yes, now I can see your post (But still my post says 8 Messages
and I am ble to see only 6).

Thanks for the suggestion. Being a programmer (in C Language)
I was taught not to use "Goto" as a primary rule.

But if you are suggesting this then there must be no ther way.

Thank you again for showing the way.


It is not that GoTo should never be used; it's just that it should not be
misused. In order to duplicate the "Continue" statement that other languages
have, the construction I used is pretty much it. Now, it should only be used
when you are going to have multiple points within your loop where you will
want to skip to the next loop iteration from. For the simple construction
you gave, I would just use an If-Then housing to perform the "skip". Using
the structure of your originally posted code, something like this could be
used to skip to the next loop iteration...

Do While some_condition = TRUE
'-----Some Code----
If this_condition = FALSE Then
'-----Some Code----
End If
Loop

But, as I said, this is a simple construction. As you add more and more
points to "Continue" from, the nesting of the various "Continue points" can
get quite messy quite quickly; and the inverted logical tests in the various
If-Then statements to implement it can get harder and harder to follow if
you ever have to come back to the loop to modify it at some future date. The
GoTo solution I posted earlier simplifies the overall construction while
allowing you to keep your logical If-Then tests in the way you would
naturally think of them.

Rick

  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default returning back to loop check condition without completing theloop

On Mar 31, 7:36*pm, Dave Peterson wrote:
Why not use the "nested if" if you don't like GoTo's?





ashish128 wrote:

On Mar 31, 12:59 pm, "Rick Rothstein \(MVP - VB\)"
wrote:
Hoping that you will be able to see this response from me, here is what I
posted originally...


You could use a Label Statement and a GoTo statement like this...


Do While some_condition = TRUE
* * '-----Some Code----
* * If this_condition = TRUE then GoTo Continue
* * '-----Some Code----
Continue:
Loop


Please indicate if you can see this message.


If Ashish doesn't respond in a reasonable time period, will someone be kind
enough to copy and post it back to Ashish for me.


Rick


"ashish128" wrote in message


....
On Mar 24, 5:35 pm, Dave Peterson wrote:


You didn't like Rick's reply?


ashish128 wrote:


On Mar 18, 8:30 pm, Dave Peterson wrote:
Do While some_condition = TRUE


'-----Some Code----


If this_condition = TRUE then
'do nothing
else
'some code here
End If


'no code here!!!!
loop


ashish128 wrote:


Hi All,


I apologise if this question has been posted before but to be true,
I
could not find it.


I have a very little question. Please see below


Do While some_condition = TRUE


'-----Some Code----


If this_condition = TRUE then


' Here I would like to send the execution back to "Do
While some_condition = TRUE"
' and bypass all succeeding lines of code


End If


'-----Some Code----


loop


Kindly let me know if this is supported / possible in VBA.


Regards


Ashish


--


Dave Peterson- Hide quoted text -


- Show quoted text -


Dear Dave,


My question is to break the process flow in middle of a loop and
restart it from the loop condition checking.


Regards


--


Dave Peterson- Hide quoted text -


- Show quoted text -


Dear Dave,


I must say that there is some problem with the GUI.


My post says 6 messages but I cannot view more than 4 (two mine and
two of yours)


Therefore I dont even know if Rick has suggested some solution.


Please convey my apologies to Rick (If you can) as I cannot see a
single post of his.


Thank You.


Regards- Hide quoted text -


- Show quoted text -


Dear Rick,


Yes, now I can see your post (But still my post says 8 Messages and I
am ble to see only 6).


Thanks for the suggestion. Being a programmer (in C Language) I was
taught not to use "Goto" as a primary rule.


But if you are suggesting this then there must be no ther way.


Thank you again for showing the way.


Regards


--

Dave Peterson- Hide quoted text -

- Show quoted text -


Dear Dave,

To be true, I didn't use "nested if" because I was preferring a clean
solution as otherwise it would cause me to have (many if and) deep
look into my code for any alteration if I break the loop at many
points.

Second truth, It didnt came to my mind :)

I am applying Rick's suggestion to get the code work as intended.

Thanks for your guidance (If it had not been you pointing to Rick's
Post I would have never come to know about it)

Regards
  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default returning back to loop check condition without completing theloop

On Mar 31, 8:00*pm, "Rick Rothstein \(MVP - VB\)"
wrote:
*I apologise if this question has been posted before but to be true,
*I could not find it. I have a very little question. Please see below


Do While some_condition = TRUE
*'-----Some Code----
*If this_condition = TRUE then
*' Here I would like to send the execution back to "Do
*While some_condition = TRUE"
*' and bypass all succeeding lines of code
*End If
*'-----Some Code----
*loop


Kindly let me know if this is supported / possible in VBA.


You could use a Label Statement and a GoTo statement like this...


Do While some_condition = TRUE
'-----Some Code----
If this_condition = TRUE then GoTo Continue
'-----Some Code----
Continue:
Loop


Dear Rick,


Yes, now I can see your post (But still my post says 8 Messages
and I am ble to see only 6).


Thanks for the suggestion. Being a programmer (in C Language)
I was taught not to use "Goto" as a primary rule.


But if you are suggesting this then there must be no ther way.


Thank you again for showing the way.


It is not that GoTo should never be used; it's just that it should not be
misused. In order to duplicate the "Continue" statement that other languages
have, the construction I used is pretty much it. Now, it should only be used
when you are going to have multiple points within your loop where you will
want to skip to the next loop iteration from. For the simple construction
you gave, I would just use an If-Then housing to perform the "skip". Using
the structure of your originally posted code, something like this could be
used to skip to the next loop iteration...

Do While some_condition = TRUE
* * '-----Some Code----
* * If this_condition = FALSE Then
* * * * '-----Some Code----
* * End If
Loop

But, as I said, this is a simple construction. As you add more and more
points to "Continue" from, the nesting of the various "Continue points" can
get quite messy quite quickly; and the inverted logical tests in the various
If-Then statements to implement it can get harder and harder to follow if
you ever have to come back to the loop to modify it at some future date. The
GoTo solution I posted earlier simplifies the overall construction while
allowing you to keep your logical If-Then tests in the way you would
naturally think of them.

Rick- Hide quoted text -

- Show quoted text -


Dear Rick,

I agree to the points.

I will be using "Goto" only where no other logical flow exists.

Thanks again for your great help

Regards
  #14   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default returning back to loop check condition without completing the loop

If the code starts looking too bad, you could always call subroutines from
either branch of your if/then/else statement. And do all the detail work there.

ashish128 wrote:

<<snipped

Dear Dave,

To be true, I didn't use "nested if" because I was preferring a clean
solution as otherwise it would cause me to have (many if and) deep
look into my code for any alteration if I break the loop at many
points.

Second truth, It didnt came to my mind :)

I am applying Rick's suggestion to get the code work as intended.

Thanks for your guidance (If it had not been you pointing to Rick's
Post I would have never come to know about it)

Regards


--

Dave Peterson
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 through column(s) to check values, perform action based on check ward376 Excel Programming 4 November 6th 07 03:21 PM
Add a second condition to loop Casey[_112_] Excel Programming 5 July 6th 06 11:59 PM
Loop or condition? To check down the rows KH_GS Excel Programming 4 March 29th 06 09:42 AM
Using For loop to condition bundyloco[_6_] Excel Programming 1 August 19th 05 07:25 PM
two-condition loop Jamie Martin[_2_] Excel Programming 0 October 6th 03 11:47 PM


All times are GMT +1. The time now is 03:23 AM.

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

About Us

"It's about Microsoft Excel"