Hi Elton; let me try explaining this.
=SUMPRODUCT((A1:A20<>"")/COUNTIF(A1:A20,A1:A20&""))
--First part of the formula (A1:A20<>"") is to check whether each cell is
blank or not which returns an array of TRUE and FALSE. All blanks will return
FALSE and non-blanks will return TRUE. Here TRUE equates to 1 and FALSE
equates to 0.
--Second part of the formula is to COUNT the number of each entry in the
range. =COUNTIF(A1:A20,A1&""). So this will return the count of A1 in that
range; non-duplicates will return 1, duplicates will return the number of
times it has been duplicated,blank entries will return the number of blank
cells. So =COUNTIF(A1:A20,A1:A20&"") will return an array of this count; the
array size is exactly same as the array returned from the first part.
--Third part of the formula is to divide the 'first part' which is TRUE
/FALSE or 1 or 0 with the second part (which is the count of each entry). So
non duplicates will equate to (1 divided by 1) which returns 1 itself.
Duplicates for example if the count for an entry is 2 ; 1 divided by 2 will
return 0.5. If there are 3 instances of the entry 1 divided by 3 will return
3.333.. etc;for each entry. So the sum of duplicates also will return 1. For
blanks the division happens FALSE/the count of blanks which equate to 0.
--The final SUMPRODUCT adds up all the array values returned to return the
count. Here duplicates (fractions whch add up to 1) and non-duplicates (1's),
blanks (0's) are added to return the distinct count.
PS: Another way of counting unique values among duplicates is explained in
the below link which uses the function FREQUENCY()
http://office.microsoft.com/en-us/excel/HP030561181033.aspx
If this post helps click Yes