View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Beto[_3_] Beto[_3_] is offline
external usenet poster
 
Posts: 140
Default Delete rows that DO NOT contain certain text

Beto wrote:

Steph wrote:

Hi. I have a file that has several sheets, and each sheet is about
40k rows long. It was an import from a text file. In column B is a
long text string. I need to delete all rows in every sheet that DO
NOT contain the word "logoff" OR "timeout" OR "logon" somewhere in the
cell in column B.


Do'h, I did it the other way around... I'll fix it now.


Sub EraseCertainRows()
Application.ScreenUpdating = False
For Each cell In Range("B:B")
If InStr(1, cell.Value, "logoff") < 0 Or _
InStr(1, cell.Value, "logon") < 0 Or _
InStr(1, cell.Value, "timeout") < 0 Then
cell.EntireRow.Delete
End If
Next cell
Application.ScreenUpdating = True
End Sub



--
Beto
Reply: Erase between the dot (inclusive) and the @.
Responder: Borra la frase obvia y el punto previo.