+ Reply to Thread
Results 1 to 9 of 9

Counting Unique Values in a Named Range using COUNTIF

  1. #1
    Registered User
    Join Date
    02-20-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2008 for Mac
    Posts
    4

    Counting Unique Values in a Named Range using COUNTIF

    Currently trying to search for unique client ID #s across a large database with non-contiguous fields. I created a named range to hold all of the client ID fields. Currently playing with these two formulas, but I keep getting a #VALUE! error.

    Option 1: =SUMPRODUCT((clientid<>"")/COUNTIF(clientid,clientid&""))

    Option 2: =SUMPRODUCT(1/COUNTIF(CLIENT_ID,CLIENT_ID))

    The only ideas I've got left get real messy real quick. Anyone know of any straightforward forumlas I can apply to this situation? Let me know. Thanks.
    Last edited by arsone; 02-21-2012 at 11:20 AM.

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Counting Unique Values in a Named Range using COUNTIF

    Hi and welcome to the forum.

    Your first formula, works ok for me.

    [B]=SUMPRODUCT((clientid<>"")/COUNTIF(clientid,clientid&""))[/B

    If you still have problem with this, pls upload a small sample workbook.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  3. #3
    Registered User
    Join Date
    02-20-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2008 for Mac
    Posts
    4

    Re: Counting Unique Values in a Named Range using COUNTIF

    Hmm. Still pulling an error. Fairly certain it's a careless mistake at this point, but I've been staring at it for close to three hours now. Workbook attached - thanks for taking a look.

    ActiveClients.xlsx

  4. #4
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Counting Unique Values in a Named Range using COUNTIF

    ...As you understand your Named range, is not something regular....

    My suggesttion is to copy all your values to ONE column and then use the formula!!

  5. #5
    Valued Forum Contributor
    Join Date
    07-29-2009
    Location
    Belgium
    MS-Off Ver
    Excel 2003/Excel 2010
    Posts
    534

    Re: Counting Unique Values in a Named Range using COUNTIF

    If a UDF is acceptable see attachment, cell C100;
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    02-20-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2008 for Mac
    Posts
    4

    Re: Counting Unique Values in a Named Range using COUNTIF

    I think fotis1991 is right. I was trying to find a way to avoid putting everything in one column because my employer wanted everything visually segregated by month. But unless I start building pivot tables, I think this is the best way to do it. Added a column for "month" to sort.

    One remaining problem: using the first function

    =SUMPRODUCT((CLIENT_ID<>"")/COUNTIF(CLIENT_ID,CLIENT_ID&""))

    yields a #DIV/0 error when the range includes blank cells. I can't figure out why - shouldn't the ("CLIENT_ID<>"") part preclude blank cells from the function? I tried updating the function to

    =SUMPRODUCT((CLIENT_ID<>"")/COUNTIF(CLIENT_ID,IF(CLIENT_ID=0,0,CLIENT_ID)))

    but I'm still getting a zero error. Thoughts? Thanks guys!

  7. #7
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Counting Unique Values in a Named Range using COUNTIF

    Hi

    ..yields a #DIV/0 error when the range includes blank cells. I can't figure out why - shouldn't the ("CLIENT_ID<>"") part preclude blank cells from the function?
    Why you say this??Maybe am i missing something??
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    02-20-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2008 for Mac
    Posts
    4

    Re: Counting Unique Values in a Named Range using COUNTIF

    Strange. When I save it as an '.xls' file, the function breaks and I get a zero error. When I save it as an '.xslx' file, it works. Does .xls not support named ranges? Using Excel for Mac 2008.

    Doesn't matter, it's working now. Thanks everybody for the assist!

  9. #9
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Counting Unique Values in a Named Range using COUNTIF

    You are welcome !

    So, pls mark your thread, as SOLVED!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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