I have a code that works great for finding text in a range and deleting the entire row, but I can't tweak it to have it delete a row if it finds specific text within text. To explain, I am using this for an inventory tracker. In column B I have all of the product skus. I need to delete any row that has a sku in column B that ends in "-O". We use "-O" to signify that product as an open box product, and I don't need it in this tracker. Here is the code that I am using (I understand that the way I have it set up is looking for an exact match)
'Delete the "Open Box" Rows
Dim rng As Range, cell As Range, del As Range
Set rng = Intersect(Range("B1:B" & Cells(Rows.Count, "B"). _
End(xlUp).Row), ActiveSheet.UsedRange)
For Each cell In rng
If (cell.Value) = "-O" _
Then
If del Is Nothing Then
Set del = cell
Else: Set del = Union(del, cell)
End If
End If
Next cell
On Error Resume Next
del.EntireRow.delete
'Delete the "Open Box" Rows
Dim rng As Range, cell As Range, del As Range
Set rng = Intersect(Range("B1:B" & Cells(Rows.Count, "B"). _
End(xlUp).Row), ActiveSheet.UsedRange)
For Each cell In rng
If (cell.Value) = "-O" _
Then
If del Is Nothing Then
Set del = cell
Else: Set del = Union(del, cell)
End If
End If
Next cell
On Error Resume Next
del.EntireRow.delete