Thread: Row Deletion
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Row Deletion

Hi,

You weren't particularly clear what you wanted so this will delete all rows
that don;t contain your text and retain those rows that contain the text with
NOTHING ELSE in the cell. Right click your sheet tab, view code and paste
this in and run it.

Sub copyit()
mycolumn = "c" 'Change to suit
Dim MyRange, MyRange1 As Range
LastRow = Cells(Rows.Count, mycolumn).End(xlUp).Row
Set MyRange = Range(mycolumn & "1:" & mycolumn & LastRow)
For Each c In MyRange
If UCase(c.Value) < "NORMAL WTC RUN-ON" Then
If MyRange1 Is Nothing Then
Set MyRange1 = c.EntireRow
Else
Set MyRange1 = Union(MyRange1, c.EntireRow)
End If
End If
Next
If Not MyRange1 Is Nothing Then
MyRange1.Delete
End If
End Sub

Mike

"SiH23" wrote:

I'd be most grateful if someone could offer some advice:

I need a macro which will delete all rows with the exception of those
containing the words: Normal WTC Run-on in Column C

Many thanks in advance.