+ Reply to Thread
Results 1 to 7 of 7

counting number of unique items in column

  1. #1
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,173

    counting number of unique items in column

    I am trying to count the number of unique items in a single column (~5,000 rows of data). For example, I may have the following data

    a1 = apples
    a2 = pears
    a3 = oranges
    a4 = apples
    a5 = apples
    a6 = apples
    a7 = pears

    in this case number of uniques items is 3

    Right now I am using a Pivot Table to figure out the number of unique items but I am sure there is an easier way to do this. Thanks for any comments.
    Last edited by maacmaac; 10-10-2008 at 02:18 PM.

  2. #2
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    Does this help ? =SUM(1/COUNTIF(a2:a11,a2:a11)) entered as an arry formula ( Ctrl+Shift+Enter)

  3. #3
    Forum Expert
    Join Date
    06-18-2004
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    1,474
    Try...

    =SUM(IF(FREQUENCY(IF(A1:A7<>"",MATCH("~"&A1:A7,A1:A7&"",0)),ROW(A1:A7)-ROW(A1)+1),1))

    ...confirmed with CONTROL+SHIFT+ENTER.

    Hope this helps!

  4. #4
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,173
    Domenic -

    Your solution works if I have 7 rows of data but the total number of rows varies day-to-day (usually 5000 rows to 30000 rows). I tried to adjust the formula as follows but does not work.

    =SUM(IF(FREQUENCY(IF(A:A<>"",MATCH("~"&A:A,A:A&"",0)),ROW(A:A)-ROW(A1)+1),1))

  5. #5
    Forum Expert
    Join Date
    06-18-2004
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    1,474
    Unfortunately, array formulas such as this one do not allow whole column references. If you're using Excel 2007, convert your data into a Table. The range will automatically adjust as data is added/removed. If you're using Excel 2003, convert your data into a List. Otherwise, use a dynamic named range.

    Hope this helps!

  6. #6
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    Maybe using dynamic ranges will do the trick?

  7. #7
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,173
    I think I can figure it out from here (I hope). Thanks for the link for dynamic ranges.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Count Unique Items in PivotTable?
    By EnergyEngineer in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-29-2008, 12:00 PM
  2. How to read the column which include text and number in the excel via ODBC?
    By winniewang11 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-12-2008, 06:39 AM
  3. Inserting a Column - Sometimes Works, Sometimes Not
    By teddybouch in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-11-2008, 06:52 PM
  4. Unique Random Number generator
    By David Obeid in forum Excel General
    Replies: 3
    Last Post: 01-28-2008, 11:27 PM
  5. Insert a formula with relative cell reference based on a number in a column
    By Dcritelli in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-16-2007, 05:54 PM

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