Find and delete rows

  • Thread starter Thread starter JRSmith
  • Start date Start date
J

JRSmith

Hi and TIA. What I'm trying to accomplish is to run code that checks column
A starting at A1. Run down until it finds the word "DeleteMe" and from that
row until the end of the document delete all rows. Is that possible?
Thanks for any advice and your time.
 
Give this macro a try...

Sub ProcessDeleteMe()
Dim DM As Range
With Worksheets("Sheet1")
On Error GoTo Done
Set DM = .Columns("A").Find(What:="DeleteMe", MatchCase:=False)
Application.Intersect(.UsedRange, Range(DM, .Cells( _
.Rows.Count, "A"))).EntireRow.Delete
End With
Done:
End Sub
 
Rick, Thanks for the reply. Works like a charm. Exactly what I was
looking for. At first it didn't work because the cell that held the
deleteme string was a merged cell. Once I unmerged good to go. Thanks
again for your time.


Rick Rothstein said:
Give this macro a try...

Sub ProcessDeleteMe()
Dim DM As Range
With Worksheets("Sheet1")
On Error GoTo Done
Set DM = .Columns("A").Find(What:="DeleteMe", MatchCase:=False)
Application.Intersect(.UsedRange, Range(DM, .Cells( _
.Rows.Count, "A"))).EntireRow.Delete
End With
Done:
End Sub
 
Back
Top