Counting Unique Values

K

Karen

I have a range of cells (A5:A100). In some cells there are duplicate part
numbers. I want to count ONLY the unique values and not the duplicates. Does
anyone know how this can be done and what formula I would use to accomplish
this?
Thank you very much in advance, Karen
 
T

T. Valko

One way:

=SUMPRODUCT((A5:A100<>"")/COUNTIF(A5:A100,A5:A100&""))

If there are no empty cells within the range then you can reduce that to:

=SUMPRODUCT(1/COUNTIF(A5:A100,A5:A100))
 
J

JBeaucaire

This will check the whole column, but you can restrict it to just the range
you've noted if you want.

=SUM(IF(FREQUENCY(A:A,A:A)>0,1))
 
R

ryguy7272

Thanks BerndP. That's pretty neat. I've seen other ways too. This list is
pretty comprehensive, I think:
< -- =SUMPRODUCT((A2:A105<>"")/(COUNTIF(A2:A105,A2:A105&"")))
< -- =SUMPRODUCT((A2:A998<>"")/(COUNTIF(A2:A998,A2:A998)+(A2:A998="")))
< --
=SUM(IF(FREQUENCY(IF(LEN(A2:A999)>0,MATCH(A2:A999,A2:A999,0),""),IF(LEN(A2:A999)>0,MATCH(A2:A999,A2:A999,0),""))>0,1))
Note: This is a CSE Function
< -- =SUMPRODUCT((A2:A105<>"")/COUNTIF(A2:A105,A2:A105&"")*(A2:A105<>""))
< -- =SUMPRODUCT(--(A2:A999<>""),1/COUNTIF(A2:A999,A2:A999&""))
< --
=SUM(--(FREQUENCY(IF(A2:A2705<>"",MATCH(A2:A2705,A2:A2705,0)),ROW(INDIRECT("1:"&ROWS(A2:A2705))))>0))
Note: This is a CSE Function
< -- =COUNT(1/FREQUENCY(A1:A400,A1:A400))
< -- =SUM(1/COUNTIF(C13:C17,C13:C17))
Note: This is a CSE Function & it fails if there are any blanks in between
< -- =SUM(IF(A2:A400<>"",1/COUNTIF(A2:A400,A2:A400)))
< --
=SUM(IF(FREQUENCY(IF(A2:A1001<>"",MATCH("~"&A2:A1001,A2:A1001&"",0)),ROW(A2:A1001)-ROW(A2)+1),1))

I don't believe this list is exhaustive. There are probably many other ways
of doing this. Maybe some have yet to be discovered (by anyone).

HTH,
Ryan--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top