Find and delete all other rows

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all
I am trying to get a Macro to find the word or part of the word in a cell.
All cells that do not have that word should be deleted.
If I use the follwoing it does not work

Set c = .Find("test", LookIn:=xlValues)
If c Is Nothing Then
c.EntireRow.Delete
Else
firstAddress = c.Address
Do
c.Interior.ColorIndex = 6
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
 
If the range that you're looking through is a single column, you could apply
Data|Filter|autofilter to that column.

Then filter using Custom|Does not contain|test
and delete the visible rows

And then remove the filter.
 

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

Similar Threads

Marco Exits without error 1
How to add multiple values to this macro 4
Error in Sub 4
Average Value Revisited 11
Find Macro Error 5
Should be easy...what's missing? 8
Please help with VBA code 12
FindNext Errors 6

Back
Top