I have very little knowledge/experience using VBA in Excel and I'm trying to find a way to delete entire rows if any of the cells in that row contain one of several text strings. After a google search or two I found this page:
https://excel.officetuts.net/vba/delete-a-row-if-cell-contains/
which suggested using the following code:
Sub DeleteRows()
Dim rng As Range
Dim pos As Integer
Set rng = ActiveSheet.UsedRange
For i = rng.Cells.Count To 1 Step -1
pos = InStr(LCase(rng.Item(i).Value), LCase("delete"))
If pos > 0 Then
rng.Item(i).EntireRow.Delete
End If
Next i
End Sub
The example above would delete any rows containing the text "delete" and is case insensitive.
What I would like to achieve is something similar, but with the ability to use more than one text string so that all rows containing the words "delete" or "banana" or "hospital" would be deleted for example. Is there a way to amend this sample code to achieve my goal, or would a different approach entirely be required?
Thanks in advance for your help.