LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Better Fix For Endless Do While Statement

I had to add the IF statement below to stop the Loop if MyValue wasn't found
on any of the
sheets. Is there any better way to do the following, or since this seems to
work, just leave it alone? workbook has only 8 sheets.
Thanks.

the code:

MyValue = PO_Number

Dim MyVar
On Error Resume Next
a = 1
Do While MyVar = ""
MyVar = Application.WorksheetFunction _
.Match(MyValue, Worksheets(a).Range("E1:E3000"), 0)

a = a + 1

If a = 8 And MyVar = "" Then
MsgBox ("PO # Not Found In Records.")
Exit Sub
End If

Loop
' Select sheet and cell after finding
Sheets(Worksheets(a - 1).Name).Select
Range("E" & MyVar).Select


 
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
Endless spreadsheet calculations Zsolt Szabó Excel Discussion (Misc queries) 0 September 22nd 09 03:22 AM
How can I make endless row, beyond IV column? Luciano New Users to Excel 2 January 23rd 06 04:08 PM
preventing endless loops J_J[_2_] Excel Programming 6 August 15th 05 03:19 PM
Endless loop? John Excel Programming 24 August 2nd 05 06:41 PM
Interrupting an endless loop davegb Excel Programming 3 March 17th 05 05:06 PM


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

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"