Hi!
So I have a separate sheet (called "negative") with thousands of phrases I do not want in my "data" sheet. I want to filter through column C in "data" sheet for any phrases that matches entire cell content of any items in column A of the "negative" sheet.
The filter and delete row works, except I don't know for sure if it is matching THE ENTIRE CELL CONTENT before deleting the row. It seems to be deleting when the cell contents are close to what I have on my list in my "negative" sheet.
Thanks in advance!
Sub Delete_with_Autofilter_More_Criteria()
Dim rng As Range
Dim cell As Range
Dim CriteriaRng As Range
Dim calcmode As Long
With Application
calcmode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
With Sheets("negative")
Set CriteriaRng = .Range("A1", .Cells(Rows.Count, "A").End(xlUp))
End With
'Loop through the cells in the Criteria range
For Each cell In CriteriaRng
With Sheets("data")
'Firstly, remove the AutoFilter
.AutoFilterMode = False
'Apply the filter
.Range("C1:C" & .Rows.Count).AutoFilter Field:=1, Criteria1:=cell.Value
With .AutoFilter.Range
Set rng = Nothing
On Error Resume Next
Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not rng Is Nothing Then rng.EntireRow.Delete
End With
'Remove the AutoFilter
.AutoFilterMode = False
End With
Next cell
With Application
.ScreenUpdating = True
.Calculation = calcmode
End With
End Sub
Bookmarks