how do I stop the find at the end of the sheet

  • Thread starter Thread starter djh
  • Start date Start date
D

djh

I need to handle the first find and delete a bit
differently than the rest. After the first one, I want
to repeatedly search from a few rows down from the first
one until the end of the sheet, doing deletes. How do I
stop the loop from continuing back to the start of the
worksheet, finding text that I intentionally left behind.

--------
Range("A1").Activate

Range(Cells.Find("PAUL INC").Offset(-2, 0), Cells.Find
("======").Offset(-3, 0)).EntireRow.Delete

Range("A1").Offset(4, 0).Activate

Do Until Cells.Find("PAUL INC") Is Nothing

Range(Cells.Find("PAUL INC").Offset(-2, 0), Cells.Find
("======").Offset(1, 0)).EntireRow.Delete

Loop
 
djh said:
I need to handle the first find and delete a bit
differently than the rest. After the first one, I want
to repeatedly search from a few rows down from the first
one until the end of the sheet, doing deletes. How do I
stop the loop from continuing back to the start of the
worksheet, finding text that I intentionally left behind.

--------
Range("A1").Activate

Range(Cells.Find("PAUL INC").Offset(-2, 0), Cells.Find
("======").Offset(-3, 0)).EntireRow.Delete

Range("A1").Offset(4, 0).Activate

Do Until Cells.Find("PAUL INC") Is Nothing

Range(Cells.Find("PAUL INC").Offset(-2, 0), Cells.Find
("======").Offset(1, 0)).EntireRow.Delete

Loop

What is often done is to save the address of the starting cell and check
each time to see if Find has returned to it.
 
-----Original Message-----


What is often done is to save the address of the starting cell and check
each time to see if Find has returned to it.

--
Bob Kilmer


.
I'm new to VBA, and am doing somewhat of a trial and
error, looking in Help for examples. What would be the
syntax of that save and comparison since I have the
offset and delete with the cells.find and range?
 
Back
Top