Thread
:
delete all rows except
View Single Post
#
2
Posted to microsoft.public.excel.programming
Don Guillett
external usenet poster
Posts: 10,124
delete all rows except
Sub Delete_Row()
For i = Cells(Rows.Count, "a"). _
End(xlUp).Row To 2 Step -1
If InStr(UCase(Cells(i, "a")), "xxx")<1 _
or InStr(UCase(Cells(i, "a")), "yyy")<1 then _
Rows(i).Delete
Next i
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
"J.W. Aldridge" wrote in message
...
need to delete all rows except those containing "apples" and or
"oranges" in column G.
code below works, just need to add second criteria.
assuming that "a" would be changed to "g".
Sub Delete_Row()
For i = Cells(Rows.Count, "a"). _
End(xlUp).Row To 2 Step -1
If InStr(UCase(Cells(i, "a")), "MZ")<1 _
Then Rows(i).Delete
Next i
End Sub
Reply With Quote
Don Guillett
View Public Profile
Find all posts by Don Guillett