View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Roger Govier[_3_] Roger Govier[_3_] is offline
external usenet poster
 
Posts: 2,480
Default Macro for fast deletion of rows that conatin certain data.

Hi Phil

I would loop through the file starting at the last row and build a
collection of the rows with the text 6:00 AM in them, then delete that
collection at the finish of the routine.

Sub DeleteRows6AM()
Dim lr As Long, i As Long
Dim delrng As Range, ws As Worksheet
Set ws = ActiveSheet
lr = ws.Cells(Rows.Count, 2).End(xlUp).Row
For i = lr To 1 Step -1
If Cells(i, 2).Text = "6:00 AM" Then
If delrng Is Nothing Then
Set delrng = ws.Rows(i)
Else
Set delrng = Application.Union(delrng, ws.Rows(i))
End If
End If
Next
delrng.Delete
End Sub

--
Regards
Roger Govier

"PhilBennett" wrote in message
...
I need a macro that deletes all rows in a worksheet in which a certain
text
string is found in a cell in that row? e.g. If a cell in column "B"
contains
a text string "6:00 AM", then delete the entire row.

__________ Information from ESET Smart Security, version of virus
signature database 4527 (20091020) __________

The message was checked by ESET Smart Security.

http://www.eset.com




__________ Information from ESET Smart Security, version of virus signature database 4527 (20091020) __________

The message was checked by ESET Smart Security.

http://www.eset.com