This article shows this for text values:
=SUM(IF(FREQUENCY(IF(LEN(C3:C25)>0,MATCH(C3:C25,C3:C25,0),""), IF(LEN(C3:C25)>0,MATCH(C3:C25,C3:C25,0),""))>0,1))
and this for numeric values:
=SUM(IF(FREQUENCY(C3:C25, C3:C25)>0,1))
This article shows similar formulas, but also shows a method using filters.
Count the number of unique values by using a filter
You can use the Advanced Filter to extract the unique values from a column of data and paste them to a new location. Then you can use the ROWS function to count the number of items in the new range.
- Ensure that the first row in the column has a column header.
- On the Data menu, point to Filter, and then click Advanced Filter.
- In the Advanced Filter dialog box, click Copy to another location.
- If the range that you are counting is not already selected, delete any information in the List range box and then click the column (or select the range) that contains your data.
- In the Copy to box, delete any information in the box or click in the box, and then click a blank column where you want to copy the unique values.
Select the Unique records only check box, and click OK.
The unique values from the selected range are copied to the new column.
In the blank cell below the last cell in the range, enter the ROWS function. Use the range of unique values that you just copied as the argument. For example, if the range of unique values is B1:B45, then enter:
=ROWS(B1:B45)
for each [i] in A2:A100 DO:{ sum += (([i]<>"")/COUNTIF(A2:A100,[i])) }, right? I am having a little trouble understanding how it knows to enumerate both the conditional and the 2nd COUNTIF parameter, but *not* the 1st COUNTIF parameter? Is this DWIM-magic documented/explained anywhere by MS? It would be nice to know how to write these intentionally. – RBarryYoung Apr 25 '13 at 21:41=SUMPRODUCT((A2:A100<>"")/COUNTIF(A2:A100,A2:A100&"")). It ensures that theCOUNTIFnever returns a 0 for blank lines, which would result in aDIV/0error. – cfi Jul 04 '13 at 09:19%? The percent character does not work in Excel 2010 for appending text. It is the ampersand&that does the trick. – cfi Jul 08 '13 at 07:48