Just a couple of points regarding your post.
First, you have this declaration line in your code...
Dim MyRange, MyRange1 As Range
I just want to point out that only MyRange1 is declared as a Range
variable... MyRange is defaulted to a Variant. VB/VBA requires each variable
to be individually declared as to Type or else it gets defaulted to a
Variant.
Second, when the concept of accumulating (via the Union function) first came
up, someone (sorry, the name escapes me at the moment) pointed out there was
a limit to how many areas can be grouped like that (I think it was 8000+,
whichever power of 2 equates to that); but it was noted that before that
limit is reached, the grouping will start to bog down. Here is the code
module I came up with that accounts for the above (and also shuts off
automatic calculations and screen updating to help speed things up)...
***************** START OF CODE *****************
Sub ConditionalDelete()
Dim X As Long
Dim Z As Long
Dim LastRow As Long
Dim FoundRowToDelete As Boolean
Dim OriginalCalculationMode As Long
Dim RowsToDelete As Range
Dim SearchItems() As String
Dim DataStartRow As Long
Dim SearchColumn As String
Dim SheetName As String
' Set your search conditions here
DataStartRow = 1
SearchColumn = "B"
SheetName = "Sheet1"
' Put your search strings in the comma delimited string
SearchItems = Split("img,aboutus,othertext,etc", ",")
On Error GoTo Whoops
OriginalCalculationMode = Application.Calculation
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
With Worksheets(SheetName)
LastRow = .Cells(.Rows.Count, SearchColumn).End(xlUp).Row
For X = LastRow To DataStartRow Step -1
FoundRowToDelete = False
For Z = 0 To UBound(SearchItems)
If InStr(.Cells(X, SearchColumn).Value, SearchItems(Z)) Then
FoundRowToDelete = True
Exit For
End If
Next
If FoundRowToDelete Then
If RowsToDelete Is Nothing Then
Set RowsToDelete = .Cells(X, SearchColumn)
Else
Set RowsToDelete = Union(RowsToDelete, .Cells(X, SearchColumn))
End If
If RowsToDelete.Areas.Count > 100 Then
RowsToDelete.EntireRow.Delete
Set RowsToDelete = Nothing
End If
End If
Next
End With
If Not RowsToDelete Is Nothing Then
RowsToDelete.EntireRow.Delete
End If
Whoops:
Application.Calculation = OriginalCalculationMode
Application.ScreenUpdating = True
End Sub
***************** END OF CODE *****************
Rick