Hi,
I have two Macros that Delete unique Values:
Public Sub DeleteUnique()
Dim rngData As Range
Set rngData = Range(Cells(2, "A"), Cells(Rows.Count, "A").End(xlUp))
With rngData.Offset(, Columns.Count - 1)
.FormulaR1C1 = "=IF(COUNTIF(" & rngData.Address(1, 1, xlR1C1) & ",RC1)=1,""x"",0)"
.Calculate
On Error Resume Next
.SpecialCells(xlCellTypeFormulas, xlTextValues).EntireRow.DELETE
On Error GoTo 0
.Clear
End With
Set rngData = Nothing
End Sub
and
Sub Del_Unique()
Application.ScreenUpdating = False
Columns("B:B").Insert Shift:=xlToRight
Columns("A:A").copy Destination:=Columns("B:B")
i = Application.CountIf(Range("A:A"), "<>") + 50
If i > 65536 Then i = 65536
Do
If Application.CountIf(Range("B:B"), Range("A" & i)) = 1 Then
Rows(i).DELETE
End If
i = i - 1
Loop Until i = 0
Columns("B:B").DELETE
Application.ScreenUpdating = False
End Sub
both of them give inaccurate results.
I make sure I Round the values to 4 decimal places so my data is uniform but still these macros delete some duplicate values and I can't have that.
Can you see where they go wrong or how they can be improved?
Which one is the better approach?
Thanks for any help.
Bookmarks