+ Reply to Thread
Results 1 to 8 of 8

Count unique values in a range

Hybrid View

  1. #1
    Registered User
    Join Date
    08-15-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    40

    Count unique values in a range

    Hi There,

    I have a range which is filled with different City names. There are totally 10,000 City names and only 220 are unique entries.

    I want a formula which will help me count the number of unique values in a range.

    Please help.

    Thanks in advance.

    VJ

  2. #2
    Forum Contributor thameem127's Avatar
    Join Date
    04-06-2012
    Location
    Jeddah,Saudi Arabia
    MS-Off Ver
    Excel 2003,Excel 2007
    Posts
    321

    Re: Count unique values in a range

    Use this formula.

    
    COUNTIF(A2:A100,A2:A100))

  3. #3
    Registered User
    Join Date
    08-15-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Count unique values in a range

    Sample File.xlsxSample File.xlsxThank you thameem127.

    I have attached my sample file and the answer I am expecting is 3 as there are only 3 unique values.

    Can you tweak your formula by looking at my sample file.

    Thanks,
    VJ

  4. #4
    Forum Contributor thameem127's Avatar
    Join Date
    04-06-2012
    Location
    Jeddah,Saudi Arabia
    MS-Off Ver
    Excel 2003,Excel 2007
    Posts
    321

    Re: Count unique values in a range

    Try this attached file.Copy of Sample File coun if.xlsx

  5. #5
    Registered User
    Join Date
    02-11-2013
    Location
    Calgary
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Count unique values in a range

    Hi there, I've been working on the same question. This is best solution I've come across so far, found here at office.microsoft.com

    I feel like there must be a simpler solution, so I'll be watching to see if one pops up

    applied to your sample file:
    Copy of Sample File-1.xlsx

    This is how I've used it:

    =SUM(IF(FREQUENCY(IF(LEN(B4:B4000)>0,MATCH(B4:B4000,B4:B4000,0),""), IF(LEN(B4:B4000)>0,MATCH(B4:B4000,B4:B4000,0),""))>0,1))
    It is an array formula, so be sure to hit cntrl+shift+enter

    jenny

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Count unique values in a range

    try this....
    =SUMPRODUCT((A2:A200<>"")/COUNTIF(A2:A200,A2:A200&""))
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  7. #7
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Count unique values in a range

    =COUNTIF(A2:A101,A2:A101) is exactly the same result as =COUNTIF(A2:A101,A2)
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  8. #8
    Registered User
    Join Date
    08-15-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Count unique values in a range

    Thank you All for your kind help and time. This helped and resolved.

+ 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