![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Location: San Antonio, TX
Posts: 187
|
I have a quick little loop that I wrote to search for a certain value in a cell, but I need a "second stop" Sometimes on this report, it the item was not used in a particular day, it will not show up, therefore, my loop would run forever with out stopping, I would like it to stop when it reachs row 1000. Here is what I have so far....
Do Until Left(ActiveCell, 3) = Range _("seg1").Value ActiveCell.Offset(1, 0).Select Loop I am stumped!!
__________________
Russell |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Feb 2002
Location: Leicestershire, U K
Posts: 160
|
It looks like I can help you and you can help me.
Please view my routine as that will stop at the bottome of the range, but I cannot get it to select what I want. KK |
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Winnipeg
Posts: 2,330
|
Try inserting an IF statement. Something like:
Do Until Left(ActiveCell, 3) = Range _("seg1").Value ActiveCell.Offset(1, 0).Select If Selection.Row > 1000 Then Exit Loop Loop
__________________
Barrie Davidson "You're only given a little spark of madness. You mustn't lose it." - Robin Williams |
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Feb 2002
Location: San Antonio, TX
Posts: 187
|
it did not work, when typing in the new line, it gives me a compile error:
Expected: Do or For or Sub or Function or Property. but I did type it in exactly.... If Selection.Row > 1000 Then Exit Loop Loop What am I doing wrong??
__________________
Russell |
|
|
|
|
|
#5 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Winnipeg
Posts: 2,330
|
Quote:
Code:
Do Until Left(ActiveCell, 3) = Range("seg1").Value
ActiveCell.Offset(1, 0).Select
If Selection.Row > 1000 Then Exit Loop
Loop
__________________
Barrie Davidson "You're only given a little spark of madness. You mustn't lose it." - Robin Williams |
|
|
|
|
|
|
#6 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Portland, OR USA
Posts: 1,374
|
I believe that it's Exit Do (not loop), and you could also do something like this:
Do Until Left(ActiveCell, 3) = Range("seg1").Value Or Selection.Row > 1000 ActiveCell.Offset(1, 0).Select '... Loop -rh |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|