Excel: Find unique values in column

| | No TrackBacks

Excel: Find unique values in column

Sub FindUniqueValues()
    Call Rows("1:1").Insert(Shift:=xlDown)
    Range("A1").Value = "Email"
    Range("B1").Value = "Unique"
    Call Columns("A:B").Sort(Key1:=Range("A2"), _
        Order1:=xlAscending, Header:=xlYes, _
        OrderCustom:=1, MatchCase:=False, _
        Orientation:=xlTopToBottom, _
        DataOption1:=xlSortNormal)
        
    Dim wks As Worksheet
    Set wks = ThisWorkbook.ActiveSheet
    Dim startCell As Range, endCell As Range:
    Set startCell = Range("B2")
    Set endCell = wks.Cells.SpecialCells(xlCellTypeLastCell)
    startCell.FormulaR1C1 = "=RC[-1]<>R[1]C[-1]"
    Dim r As Range
    Set r = Range(startCell, endCell)
    Call startCell.AutoFill(Destination:=r)
    Call wks.Calculate
    Set r = Columns("A:B")
    Call r.AutoFilter
    Call r.AutoFilter(Field:=2, Criteria1:="TRUE")
End Sub

No TrackBacks

TrackBack URL: http://www.iwebthereforeiam.com/cgi-bin/mt/mt-tb.cgi/230

Leave a comment

Verification (needed to reduce spam):

Pages

OpenID accepted here Learn more about OpenID
Powered by Movable Type 4.32-en

About this Entry

This page contains a single entry by Hugh Brown published on April 25, 2007 6:38 AM.

n Guilty Men was the previous entry in this blog.

Python analytics is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.