Link to home
Start Free TrialLog in
Avatar of U_S_A
U_S_A

asked on

Removing Duplicates From A List

I have a list that i need to remove all Duplicates, if I find any,

example
List
1
1
2
3
3
4
5
5

Goal
2
4

I have open office calc and I have Notepadd++

Thank you in advance.
ASKER CERTIFIED SOLUTION
Avatar of NBVC
NBVC
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Just add a count column next to your list in Excel with the formula:
=COUNTIF(A:A,A2)

Open in new window

User generated image
Then apply filters and select only 1 in the count column:
User generated imageUser generated imageExample.xlsx
Dim Rw As Double, WS As Worksheet

Sub Keep_Unique()

    Set WS = Sheets("Sheet1")
    
    Rw = WS.Cells(Rows.Count, 1).End(xlUp).Row

    WS.Cells(1, 1).Value = "Values"
    WS.Range(WS.Cells(2, 2), WS.Cells(Rw, 2)).FormulaR1C1 "=IF(OR(RC[-1]=R[-1]C[-1],RC[-1]=R[1]C[-1]),1,0)"
    WS.Range(WS.Cells(1, 1), WS.Cells(1, 2)).AutoFilter Field:=2, Criteria1:=1
    WS.Range(WS.Cells(2, 1), WS.Cells(Rw, 2)).SpecialCells(xlCellTypeVisible).EntireRow.Delete
    WS.Range(WS.Cells(1, 1), WS.Cells(Rw, 2)).AutoFilter
    WS.Columns(2).Delete
    
End Sub

Open in new window

End Sub
Sub Keep_Unique()

    Set WS = Sheets("Sheet1")
    
    Rw = WS.Cells(Rows.Count, 1).End(xlUp).Row

    WS.Cells(1, 1).Value = "Values"
    WS.Range(WS.Cells(1, 1), WS.Cells(Rw, 1)).Sort Key1:=WS.Cells(1, 1), Order1:=xlAscending, Header:=xlYes
    WS.Range(WS.Cells(2, 2), WS.Cells(Rw, 2)).FormulaR1C1 = "=IF(OR(RC[-1]=R[-1]C[-1],RC[-1]=R[1]C[-1]),1,0)"
    WS.Range(WS.Cells(1, 1), WS.Cells(1, 2)).AutoFilter Field:=2, Criteria1:=1
    WS.Range(WS.Cells(2, 1), WS.Cells(Rw, 2)).SpecialCells(xlCellTypeVisible).EntireRow.Delete
    WS.Range(WS.Cells(1, 1), WS.Cells(Rw, 2)).AutoFilter
    WS.Columns(2).Delete
    
End Sub

Open in new window

Forgot the line to properly sort
bearblack, does OO really support VBA? Now I have to go look...

I am assuming OO does not have the remove duplicates feature like Excel 2007 has.

Looks like it's got something, which is described here:

http://www.wikihow.com/Remove-Duplicates-in-Open-Office-Calc
Sorry -- Missed the OO part thanks for the catch