I'm trying to write a Macro which will delete every row, apart from those which contain some specific text.
I need to have the following criteria:
- Never delete the first 2 rows
- Exclude the rows where the word "Somme" can be found in column C or D.
Note, the word Somme if part of a string in column C or D. An example of the text found would be something like:
Somme alpha/000284727819293
What I have so far is code which deletes rows with Somme in it, however i need the opposite:
Sub CleanUp()
Dim c As Range
Dim SrchRng
Set SrchRng = ActiveSheet.Range("D3", ActiveSheet.Range("D65536").End(xlUp))
Do
Set c = SrchRng.Find("Somme", LookIn:=xlValues)
If Not c Is Nothing Then c.EntireRow.Delete
Loop While Not c Is Nothing
End Sub