+ Reply to Thread
Results 1 to 4 of 4

Counting unique values

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    09-09-2009
    Location
    Columbus. Ohio
    MS-Off Ver
    Excel 2000
    Posts
    199

    Counting unique values

    I am looking for a formula that will look at the values in column "C" and return a sequential count of column "C" in column "D". The attached file should make my desired result much clearer.

    JIm O
    Attached Files Attached Files
    Last edited by Jogier505; 02-14-2011 at 04:55 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Counting unique values

    Try:

    =IF(C2=C1,D1,D1+1)

    copied down

    or

    =D1+(C2<>C1)
    Last edited by NBVC; 02-14-2011 at 04:51 PM.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Contributor
    Join Date
    09-09-2009
    Location
    Columbus. Ohio
    MS-Off Ver
    Excel 2000
    Posts
    199

    Re: Counting unique values

    NBVC,

    You are a god send. I have over 2000 rows to count and I was not looking forward to a manual count of any kind.

    Thank you.
    Jim O

  4. #4
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Counting unique values

    You could try this user defined function.

    Function CountUniqueValues(MyRange As Range) As Long
    Dim MyArray() As String
    Dim Cell As Range
    Dim NewValue As Boolean
    Dim N As Long
    ReDim MyArray(0)
    For Each Cell In MyRange
        NewValue = True
        For N = 1 To UBound(MyArray)
            If MyArray(N) = Cell.Value Then
                NewValue = False
                Exit For
            End If
        Next N
        If NewValue = True Then
            ReDim Preserve MyArray(UBound(MyArray) + 1)
            MyArray(UBound(MyArray)) = Cell.Value
        End If
    Next Cell
    CountUniqueValues = UBound(MyArray)
    End Function
    Use =CountUniqueValues(C$2:C2) in Cell D2

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1