Using AdvancedFilter is a good way to remove duplicates for xl2003; however your added condition of keeping all "--" rows, makes that more difficult. To do this with AdvancedFilter, you would probably need to have two filter-copy steps or use a formula-based criteria instead with Unique=False.
Here is some code you could try that uses a temporary column of formulas to mark those to be deleted.
Sub Delete_Dups_with_Exception()
Dim lCol As Long, lRow As Long, i As Long
lCol = Cells.Find(What:="*", _
After:=Cells(1, Cells.Columns.Count), _
SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
lRow = Range("E" & Rows.Count).End(xlUp).Row
If lRow < 8 Then Exit Sub
On Error GoTo CleanUp
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
With Range("E8:E" & lRow)
'---Fill temp column with fomulas to mark rows to delete
With Cells(.Row, lCol + 1).Resize(.Rows.Count)
.FormulaR1C1 = "=IF(OR(RC5=""--"",MATCH(RC5,C5,0)=ROW(RC)),""Keep"","""")"
.Value = .Value
.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End With
End With
CleanUp:
If lCol > 0 Then Columns(lCol + 1).ClearContents
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
This just looks for duplicates in Column E. You could repeat the process for Column K, or try to modify the formula to do it in one pass.
Bookmarks