Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
djh djh is offline
external usenet poster
 
Posts: 8
Default how do I stop the find at the end of the sheet

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 280
Default how do I stop the find at the end of the sheet

"djh" wrote in message
...
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.

--
Bob Kilmer


  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default how do I stop the find at the end of the sheet


-----Original Message-----
"djh" wrote in

message
...
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.

--
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?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default how do I stop the find at the end of the sheet

See the 'FindNext Method' example in the VBE help.

HTH
Paul
--------------------------------------------------------------------------------------------------------------
Be advised to back up your WorkBook before attempting to make changes.
--------------------------------------------------------------------------------------------------------------

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


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
Find empty cell then stop Dolphinv4 Excel Discussion (Misc queries) 1 May 28th 08 02:24 PM
Stop and start Sheet recalculation jlclyde Excel Discussion (Misc queries) 0 January 29th 08 04:08 PM
How can you make the Find function stop when it reached the end kikilein Excel Discussion (Misc queries) 1 February 3rd 07 02:50 PM
VBA to stop XL from adding the Path Sring to Sheet-to-Sheet Links [email protected] Excel Discussion (Misc queries) 5 August 18th 06 01:46 PM
How to stop Excel from doing wrong Find/Replace Nekodvoru Excel Discussion (Misc queries) 3 August 7th 06 06:59 PM


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