Row Deletion

S

SiH23

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.
 
M

Mike H

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top