I need to be able to delete rows that 'do not' contain one of 5 different words. The spreadsheet contains several thousand rows so I am looking for a way to delete them quickly. I have this piece of code which deletes quickly but it deletes the rows containing the word, if I could change it to delete anything that is 'not equal' to these words it would be fine. Or a new macro :-)
Dim i As Long
Application.ScreenUpdating = False
For i = Cells(Rows.Count, 2).End(xlUp).Row To 1 Step -1
If InStr(1, Cells(i, 2).Value, "ONE", 1) Or _
InStr(1, Cells(i, 2).Value, "TWO", 1) Or _
InStr(1, Cells(i, 2).Value, "THREE", 1) Or _
InStr(1, Cells(i, 2).Value, "FOUR", 1) Or _
InStr(1, Cells(i, 2).Value, "FIVE", 1) _
Then Cells(i, 2).EntireRow.Delete
Next i
Thanks
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.