Hi Everyone,
I want to develop a code that would delete all the rows that contains cells with data "ShipTo" in column "E".
The below code is doing the opposite what I want. Its deleting everything apart from "ShipTo"
Sub Test()
Dim rng As Range, cell As Range, del As Range
Set rng = Intersect(Range("E:E"), ActiveSheet.UsedRange)
For Each cell In rng
If InStr(cell.Value, "ShipTo") = 0 Then ' delete al rows without "ShipTo"
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 '
End Sub