davidmg1982
Board Regular
- Joined
- Oct 12, 2015
- Messages
- 64
The script below does a good work removing the rows based on the duplicates found in column a, however, it removes the last line with the duplicate, what I need is to remove the first line of the dups found. I appreciate your help.
Column A
Value 1
Value 2 <- Remove
Value 2
Value 3<- Remove
Value 4
Value 3
Column A
Value 1
Value 2 <- Remove
Value 2
Value 3<- Remove
Value 4
Value 3
VBA Code:
Sub RemoveDupe()
Dim rCell As Range
Dim rRange As Range
Dim lCount As Long
Set rRange = Range("A1", Range("A" & Rows.Count).End(xlUp))
lCount = rRange.Rows.Count
For lCount = lCount To 1 Step -1
With rRange.Cells(lCount, 1)
If WorksheetFunction.CountIf(rRange, .Value) > 1 Then
.EntireRow.Delete
End If
End With
Next lCount
End Sub