I have a column that contains directories.
How can I search for cells that don't contain a keyword and remove them?
For example, if I have a column like this:
C:\Users\Desktop\Folder\html\test.html
C:\Users\Desktop\Folder\book.html
C:\Users\Desktop\Folder\Documents\test.html
C:\Users\Desktop\Folder\frontpage.html
C:\Users\Desktop\Folder\test.html
And I want to search for the keyword "test.html", I should end up with this:
C:\Users\Desktop\Folder\html\test.html
C:\Users\Desktop\Folder\Documents\test.html
C:\Users\Desktop\Folder\test.html
The 2nd and 4th lines should be deleted.
I found something that works, but takes a long time to finish if I check the entire column (so I just use 100).
Dim rng As Range
Dim cell As Range
Dim ContainWord As String
Set rng = Range("A1:A100")
ContainWord = "keyword"
For Each cell In rng.Cells
If cell.Find(ContainWord) Is Nothing Then cell.Clear
Next cell