View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
PCLIVE PCLIVE is offline
external usenet poster
 
Posts: 1,311
Default Count the number of names in a column

Thank you both, Ron and Bob, for the detailed explanations. After reading
your posts, I figured out that the reason the COUNTIF function, alone,
appeared to be producing the correct answer was because there wasn't enough
data. When I added one more name, I then got the wrong result.

Thanks for helping me understand.
Regards,
Paul

--

"Ron Coderre" wrote in message
...
First...to give credit where credit is due:
That formula was developed by Aladin Akyurek and Harlan Grove.

Within that formula's context
(A1:A10<"") checks if a cell value does not equal an empty string.
It returns a 1 for non-blanks and a 0 for blanks.

In the COUNTIF(A1:A10,A1:A10&"") section, this part: A2:A10&"" ensures
that
the COUNTIF function will always return at least 1 and never 0 (which
would
cause the formula to error out when the division is performed.)

Consequently, the numerator for blank cells is 0, so they are not counted.
The numerator for all non-blanks is 1.
The denominator for all non-blanks is their count.

If a value appears 3 times, three of the numerators will be 1 and their
respective denominators will be 3. The SUMPRODUCT function will add those
three fractions: (1/3)+(1/3)+(1/3)=1
That's how the three occurrences only count as a single instance of a
unique
value.

***********
Regards,
Ron

XL2003, WinXP


"PCLIVE" wrote:

Ron,

I'm trying to understand your formula.
For some reason, using the data provided by the OP, I get a #DIV/0!
error.
However, the COUNTIF portion gives the correct answer when used by itself
without the SUMPRODUCT.
Also, what purpose is served by the [&""] at the end? It seems to give
the
same answer with or without that.

Thanks,
Paul


--

"Ron Coderre" wrote in message
...
Try something like this:

=SUMPRODUCT((A1:A10<"")/COUNTIF(A1:A10,A1:A10&""))

Adjust the range reference to suit your situation

Does that help?
***********
Regards,
Ron

XL2003, WinXP


"James" wrote:

I have a worksheet that lists names in one column. Is there a formula
that'll
calculate the number of people represented? For example, column A
lists:

Fred
Tony
Fred
Fred
Max

The five cells represent 3 people. I'm looking for a formula that'll
tell
me
the list represents 3 people.

Thanks for your help!