Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 1
Default search for a string

How can I search for a string (Draft Documents) in sheet1 and then delete
all the rows above the row containing the string and then delete the last two
rows in sheet1? Thank you
  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 464
Default search for a string

Try;

Sub DoIt()
Dim rRange As Range

On Error Resume Next
Set rRange = Range(Cells(1, 1). _
Cells.Find("Draft Documents", _
Cells(1, 1), xlFormulas, _
xlWhole, xlByRows, xlNext, False))
On Error GoTo 0

If Not rRange Is Nothing Then
rRange.EntireRow.Delete
Else
MsgBox "'Draft Documents' Not found"
End If

Set rRange = Cells.Find("*", _
Cells(1, 1), xlFormulas, _
xlPart, xlByRows, xlPrevious, False)

rRange.Offset(-2, 0).Range("A1:A2").EntireRow.Delete
End Sub



--
Regards
Dave Hawley
www.ozgrid.com
"santana" wrote in message
...
How can I search for a string (Draft Documents) in sheet1 and then
delete
all the rows above the row containing the string and then delete the last
two
rows in sheet1? Thank you


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
Search for string containing richzip Excel Discussion (Misc queries) 5 January 14th 10 09:49 PM
Search for a text string Dan Excel Discussion (Misc queries) 1 November 10th 08 09:09 PM
How to search a string from the right ? EuroMaverick Setting up and Configuration of Excel 2 March 28th 07 09:20 PM
to search for a string and affect data if it finds the string? Shwaman Excel Worksheet Functions 1 January 11th 06 12:56 AM
Q: search in string JIM.H. Excel Discussion (Misc queries) 5 January 5th 05 10:24 PM


All times are GMT +1. The time now is 06:52 AM.

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"