Hi,
I need a macro to delete the entire row if there are any duplicates in column B. This includes the original entry row and the duplicate row.
I have been using a macro that does this but occasionally it returns an error and i am unable to work out why.
Can anybody help me with my code or give me an alternative code that will work.
Many Thanks
This is my current code:
I need a macro to delete the entire row if there are any duplicates in column B. This includes the original entry row and the duplicate row.
I have been using a macro that does this but occasionally it returns an error and i am unable to work out why.
Can anybody help me with my code or give me an alternative code that will work.
Many Thanks
This is my current code:
VBA Code:
Sub quicker_Option()
Dim toDel(), i As Long
Dim RNG As Range, Cell As Long
Set RNG = Range("b2:b200") 'set your range here
For Cell = 1 To RNG.Cells.Count
If Application.CountIf(RNG, RNG(Cell)) > 1 Then
ReDim Preserve toDel(i)
toDel(i) = RNG(Cell).Address
i = i + 1
End If
Next
For i = UBound(toDel) To LBound(toDel) Step -1
Range(toDel(i)).EntireRow.Delete
Next i
End Sub