I would like to remove a row if that row contains a specific string, but I need to do this many times for many strings.
To be more specific, my speadsheet is ~3000 rows and ~30 columns, but this changes every single day. The first column, and the only one I care about, is the name of a node on a network, and if that node starts with or contains a certain word (bananas, Apples, oranges, PINEAPPLES) I need the whole row deleted and everything to shift up
This is what I have so far with help from @chrisneilsen...
This does exactly what I need it to, but is there any code in there that I don't need, or could it be cleaned up? I've mashed up answers and suggestions from a few people and I'm wondering if I've created a monster...
Sub takeOutTheTrash()
Dim rng As Range
Dim ItemToDelete As Variant
Dim ItemsToDelete As Variant
ItemsToDelete = Array("Apple", "banana", "skittles", "grapes", "ORANGES")
Set rng = ActiveSheet.UsedRange
For Each ItemToDelete In ItemsToDelete
deleteGarbage rng, ItemToDelete
Next
End Sub
Sub deleteGarbage(rng As Range, Value As Variant)
Dim pos As Long
Dim rw As Long
Dim col As Long
For rw = rng.Rows.Count To 1 Step -1
For col = 1 To rng.Columns.Count
If InStr(LCase(rng.Cells(rw, col).Value2), LCase(Value)) > 0 Then
rng.Rows(rw).EntireRow.Delete
Exit For
End If
Next col
Next rw
End Sub