Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Feb 2001
    Location
    Terneuzen, Netherlands
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Counting unique (visible) items (Excel XP)

    I know how to count unique items in a list and I know how to count the visible items in an AutoFiltered list.
    But how do I count the unique items in a column among the visible items in an AutoFiltered list?

    Any help is much appreciated.

    Best regards,
    Cees

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Counting unique (visible) items (Excel XP)

    Add this functio to a module

    <pre>Option Explicit
    Function CountUniqueVisible(rng As Range)
    Dim rCell As Range
    Dim cNoDupes As New Collection
    For Each rCell In rng
    If Not rCell.Rows.Hidden Then
    On Error Resume Next
    cNoDupes.Add rCell.Value, CStr(rCell.Value)
    On Error GoTo 0
    End If
    Next
    CountUniqueVisible = cNoDupes.Count
    Set rng = Nothing
    Set rCell = Nothing
    End Function</pre>


    You can use it by placing in a cell something like:
    =CountUniqueVisible(A2:A100)

    to get the count of the unique visible items in A2:A100

    Steve

  3. #3
    New Lounger
    Join Date
    Feb 2001
    Location
    Terneuzen, Netherlands
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Counting unique (visible) items (Excel XP)

    Wow, that was fast.
    Thanks!

    Cees

Posting Permissions

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