Hi, exlgh91,
the code was exclusively looking for doubled lines by using WorksheetFunction.CountIf(..) = 2. If you want it changed the code must be altered as the lines to delete could interfere with other existing lines which should not be deleted.
Maybe you go have a go with
Sub Delete3()
Dim lngCounter As Long
Const cstrCOL As String = "B"
For lngCounter = Cells(Rows.Count, cstrCOL).End(xlUp).Row To 2 Step -1
Select Case WorksheetFunction.CountIf(Range(Cells(1, cstrCOL), Cells(Rows.Count, cstrCOL)), Cells(lngCounter, cstrCOL).Value)
Case 1
Cells(lngCounter, cstrCOL).EntireRow.Delete
Case 2
Range(Cells(lngCounter - 1, cstrCOL), Cells(lngCounter, cstrCOL)).EntireRow.Delete
Case 3
Range(Cells(lngCounter - 2, cstrCOL), Cells(lngCounter, cstrCOL)).EntireRow.Delete
Case Else
'do nothing
End Select
Next lngCounter
End Sub
Ciao,
Holger
Bookmarks