Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,670
Default How to exit the loop?

Does anyone have any suggestions on how to exit the loop if mycell.Text =""?
When myCell.Text is equal to "", the loop keeps going, but I would like to
exit the loop if myCell.Text is nothing or "".
Does anyone have any suggestions on how to code it?
Thanks in advance for any suggestions
Eric

Dim myRng As Range
Dim myCell As Range

For Each myCell In myRng.Cells
On Error Resume Next
Mywebsite = myCell.Text
On Error GoTo 0
' Perform task
Next myCell
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default How to exit the loop?

Eric

Put this ijn the loop

If myCell.Text = "" Then Exit For

Mike

"Eric" wrote:

Does anyone have any suggestions on how to exit the loop if mycell.Text =""?
When myCell.Text is equal to "", the loop keeps going, but I would like to
exit the loop if myCell.Text is nothing or "".
Does anyone have any suggestions on how to code it?
Thanks in advance for any suggestions
Eric

Dim myRng As Range
Dim myCell As Range

For Each myCell In myRng.Cells
On Error Resume Next
Mywebsite = myCell.Text
On Error GoTo 0
' Perform task
Next myCell

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,670
Default How to exit the loop?

Thank you very much for your suggestion
What about if myCell.Text is equal to "", then skip this one and work on
the next one? Does anyone have any suggestions on how to code it?
On the other hands, if any web link fails to access the page due to traffic
jam, the macro will be stopped and point to following line,
..Refresh BackgroundQuery:=False
Do you have any suggestions on how to skip this error and keep on for the
next one? Therefore the loop will keep going.
Thank you very much for your suggestions
Eric


"Mike H" wrote:

Eric

Put this ijn the loop

If myCell.Text = "" Then Exit For

Mike

"Eric" wrote:

Does anyone have any suggestions on how to exit the loop if mycell.Text =""?
When myCell.Text is equal to "", the loop keeps going, but I would like to
exit the loop if myCell.Text is nothing or "".
Does anyone have any suggestions on how to code it?
Thanks in advance for any suggestions
Eric

Dim myRng As Range
Dim myCell As Range

For Each myCell In myRng.Cells
On Error Resume Next
Mywebsite = myCell.Text
On Error GoTo 0
' Perform task
Next myCell

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How to exit the loop?

Dim myRng As Range
Dim myCell As Range

For Each myCell In myRng.Cells
Mywebsite = myCell.Text
if trim(mycell.text) = "" then
'skip it
else
on error resume next
'Perform task
on error goto 0
end if
Next myCell

You may want to share more of the code to get better answers.

Eric wrote:

Thank you very much for your suggestion
What about if myCell.Text is equal to "", then skip this one and work on
the next one? Does anyone have any suggestions on how to code it?
On the other hands, if any web link fails to access the page due to traffic
jam, the macro will be stopped and point to following line,
.Refresh BackgroundQuery:=False
Do you have any suggestions on how to skip this error and keep on for the
next one? Therefore the loop will keep going.
Thank you very much for your suggestions
Eric

"Mike H" wrote:

Eric

Put this ijn the loop

If myCell.Text = "" Then Exit For

Mike

"Eric" wrote:

Does anyone have any suggestions on how to exit the loop if mycell.Text =""?
When myCell.Text is equal to "", the loop keeps going, but I would like to
exit the loop if myCell.Text is nothing or "".
Does anyone have any suggestions on how to code it?
Thanks in advance for any suggestions
Eric

Dim myRng As Range
Dim myCell As Range

For Each myCell In myRng.Cells
On Error Resume Next
Mywebsite = myCell.Text
On Error GoTo 0
' Perform task
Next myCell


--

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 to Filter, Name Sheets. If Blank, Exit Loop ryguy7272 Excel Programming 3 February 5th 08 03:41 PM
exit for loop Daniel Excel Programming 2 January 3rd 08 07:36 PM
exit for next loop David Henderson Excel Programming 2 March 23rd 06 08:07 PM
exit from a loop? Kieran1028[_5_] Excel Programming 0 November 10th 04 02:55 PM
exit from a loop? crispbd[_23_] Excel Programming 0 November 8th 04 09:22 PM


All times are GMT +1. The time now is 04:37 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"