ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   How many values appear more than once in a range? (https://www.excelbanter.com/excel-worksheet-functions/20539-how-many-values-appear-more-than-once-range.html)

Bruce Norris

How many values appear more than once in a range?
 
Could someone help me out on this, please?

I have a single column range as a defined name (rngPlaces).

I want a formula in another cell to count how many values (text) appear
more than once in the range.

So...
- Values that appears only once in the list: Don't count.
- Values that appears more than once in the list: Count the value as 1.
- Blank cells: Don't count.

To further clarify - a value that appears multiple times is only
counted once.

- "Mexico City" appears 50 times: "Mexico City" counted as 1
- "Paris" appears 2 times: "Paris" counted as 1
- "Denver" appears 1 time: "Denver" counted as 0

Any ideas?

Excel 2002.

Thanks.



David McRitchie

Hi Bruce,

=COUNTIF(A$2:A9,A9)
=COUNTIF(rngPlaces,"Mexico City")

with your restriction
=(COUNTIF(rngPlaces,"Mexico City")1)+0

Summarizing Data Examples (an Overview)
http://www.mvps.org/dmcritchie/excel/sumdata.htm
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Bruce Norris" wrote in message .. .
Could someone help me out on this, please?

I have a single column range as a defined name (rngPlaces).

I want a formula in another cell to count how many values (text) appear
more than once in the range.

So...
- Values that appears only once in the list: Don't count.
- Values that appears more than once in the list: Count the value as 1.
- Blank cells: Don't count.

To further clarify - a value that appears multiple times is only
counted once.

- "Mexico City" appears 50 times: "Mexico City" counted as 1
- "Paris" appears 2 times: "Paris" counted as 1
- "Denver" appears 1 time: "Denver" counted as 0

Any ideas?

Excel 2002.

Thanks.





Bernie Deitrick

Bruce,

Array enter (enter using Ctrl-Shift-Enter)

=SUM(IF(1/COUNTIF(rngPlaces,rngPlaces)<1,1/COUNTIF(rngPlaces,rngPlaces),0))

will work as long as rngPlaces isn't a complete column (must be less than
65536 cells long)

HTH,
Bernie
MS Excel MVP





"Bruce Norris" wrote in message
.. .
Could someone help me out on this, please?

I have a single column range as a defined name (rngPlaces).

I want a formula in another cell to count how many values (text) appear
more than once in the range.

So...
- Values that appears only once in the list: Don't count.
- Values that appears more than once in the list: Count the value as 1.
- Blank cells: Don't count.

To further clarify - a value that appears multiple times is only
counted once.

- "Mexico City" appears 50 times: "Mexico City" counted as 1
- "Paris" appears 2 times: "Paris" counted as 1
- "Denver" appears 1 time: "Denver" counted as 0

Any ideas?

Excel 2002.

Thanks.





Max

Perhaps try, array-entered (CTRL+SHIFT+ENTER):

=SUM(IF(LEN(rngPlaces)0,1/COUNTIF(rngPlaces,rngPlaces)))-SUM(--(COUNTIF(rng
Places,rngPlaces)=1))

--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----
"Bruce Norris" wrote in message
.. .
Could someone help me out on this, please?

I have a single column range as a defined name (rngPlaces).

I want a formula in another cell to count how many values (text) appear
more than once in the range.

So...
- Values that appears only once in the list: Don't count.
- Values that appears more than once in the list: Count the value as 1.
- Blank cells: Don't count.

To further clarify - a value that appears multiple times is only
counted once.

- "Mexico City" appears 50 times: "Mexico City" counted as 1
- "Paris" appears 2 times: "Paris" counted as 1
- "Denver" appears 1 time: "Denver" counted as 0

Any ideas?

Excel 2002.

Thanks.





Harlan Grove

"Bruce Norris" wrote...
....
I want a formula in another cell to count how many values (text) appear
more than once in the range.

So...
- Values that appears only once in the list: Don't count.
- Values that appears more than once in the list: Count the value as 1.
- Blank cells: Don't count.

....

Another alternative,

=SUMPRODUCT((Rng<"")*(COUNTIF(Rng,Rng)1)/(COUNTIF(Rng,Rng)+(Rng="")))



Harlan Grove

"Bernie Deitrick" <deitbe @ consumer dot org wrote...
Array enter (enter using Ctrl-Shift-Enter)

=SUM(IF(1/COUNTIF(rngPlaces,rngPlaces)<1,1/COUNTIF(rngPlaces,rngPlaces),0))

....

You didn't test this with the OP's specs in mind. If the OP's range contains
blanks (and since the OP explicitly mentions this case, whatcha suppose the
odds are that there will be some blank cells?), your formula returns #DIV/0!



Bruce Norris

Hmmm. I see what your formulas do, but was looking more to answer this
question...
"How many cities in the list appear more than once?"

So, I don't want to only count "Mexico City", but any and all cities that
appear more than once. Again, I'm looking for a formula in one cell to do
this. I know I can put a special countif in an additional column within each
record then sum that up or whatever. But I'm hoping for one formula to do
it.

Any thoughts?


"David McRitchie" wrote in message
...
Hi Bruce,

=COUNTIF(A$2:A9,A9)
=COUNTIF(rngPlaces,"Mexico City")

with your restriction
=(COUNTIF(rngPlaces,"Mexico City")1)+0

Summarizing Data Examples (an Overview)
http://www.mvps.org/dmcritchie/excel/sumdata.htm
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Bruce Norris" wrote in message
.. .
Could someone help me out on this, please?

I have a single column range as a defined name (rngPlaces).

I want a formula in another cell to count how many values (text) appear
more than once in the range.

So...
- Values that appears only once in the list: Don't count.
- Values that appears more than once in the list: Count the value as 1.
- Blank cells: Don't count.

To further clarify - a value that appears multiple times is only
counted once.

- "Mexico City" appears 50 times: "Mexico City" counted as 1
- "Paris" appears 2 times: "Paris" counted as 1
- "Denver" appears 1 time: "Denver" counted as 0

Any ideas?

Excel 2002.

Thanks.







Bruce Norris

Oh, that was soooo close, but like Harlan points out, I do have some blanks
involved. Bummer.

Maybe there's no way to do this with just a formula?



"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Bruce,

Array enter (enter using Ctrl-Shift-Enter)

=SUM(IF(1/COUNTIF(rngPlaces,rngPlaces)<1,1/COUNTIF(rngPlaces,rngPlaces),0))

will work as long as rngPlaces isn't a complete column (must be less than
65536 cells long)

HTH,
Bernie
MS Excel MVP





"Bruce Norris" wrote in message
.. .
Could someone help me out on this, please?

I have a single column range as a defined name (rngPlaces).

I want a formula in another cell to count how many values (text) appear
more than once in the range.

So...
- Values that appears only once in the list: Don't count.
- Values that appears more than once in the list: Count the value as 1.
- Blank cells: Don't count.

To further clarify - a value that appears multiple times is only
counted once.

- "Mexico City" appears 50 times: "Mexico City" counted as 1
- "Paris" appears 2 times: "Paris" counted as 1
- "Denver" appears 1 time: "Denver" counted as 0

Any ideas?

Excel 2002.

Thanks.







Bruce Norris

Brilliant. That seems to work great. I don't understand it, but it works.

What is the "--" for in the syntax?

Maybe you can look at my other question,
"How to CountIf Involving Another Column"?

Thanks a bunch for your time!!


"Max" wrote in message
...
Perhaps try, array-entered (CTRL+SHIFT+ENTER):

=SUM(IF(LEN(rngPlaces)0,1/COUNTIF(rngPlaces,rngPlaces)))-SUM(--(COUNTIF(rng
Places,rngPlaces)=1))

--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----
"Bruce Norris" wrote in message
.. .
Could someone help me out on this, please?

I have a single column range as a defined name (rngPlaces).

I want a formula in another cell to count how many values (text) appear
more than once in the range.

So...
- Values that appears only once in the list: Don't count.
- Values that appears more than once in the list: Count the value as 1.
- Blank cells: Don't count.

To further clarify - a value that appears multiple times is only
counted once.

- "Mexico City" appears 50 times: "Mexico City" counted as 1
- "Paris" appears 2 times: "Paris" counted as 1
- "Denver" appears 1 time: "Denver" counted as 0

Any ideas?

Excel 2002.

Thanks.







Bruce Norris

"Harlan Grove" wrote in message
...
"Bruce Norris" wrote...
...
I want a formula in another cell to count how many values (text) appear
more than once in the range.

So...
- Values that appears only once in the list: Don't count.
- Values that appears more than once in the list: Count the value as 1.
- Blank cells: Don't count.

...

Another alternative,

=SUMPRODUCT((Rng<"")*(COUNTIF(Rng,Rng)1)/(COUNTIF(Rng,Rng)+(Rng="")))


That works too! Thanks, Harlan. I have to admit, I'm more used to Sumproduct
functions. Can you see any advantage to yours over the one Max offered?

Would you mind looking at my other question,
"How to countif involving another column"?

Thanks for all your time, Harlan.



Harlan Grove

"Bruce Norris" wrote...
"Harlan Grove" wrote in message

....
=SUMPRODUCT((Rng<"")*(COUNTIF(Rng,Rng)1)/(COUNTIF(Rng,Rng)+(Rng="")))

....
. . . Can you see any advantage to yours over the one Max offered?


Which is (using same range name)

=SUM(IF(LEN(Rng)0,1/COUNTIF(Rng,Rng)))-SUM(--(COUNTIF(Rng,Rng)=1))

Max's might be more recalc efficient, but array formulas can be perverse at
times. Max's also is shorter, which is usually better. However, I didn't
need one of my numerator tests since blank cells in Rng have count 0, so
make that

=SUMPRODUCT((COUNTIF(Rng,Rng)1)/(COUNTIF(Rng,Rng)+(Rng="")))

which is now shortest.



Max

"Bruce Norris" wrote
Brilliant. That seems to work great.
.. I don't understand it, but it works.


Some clarifications ..

SUM(IF(LEN(rngPlaces)0,1/COUNTIF(rngPlaces,rngPlaces)))

The 1st part of the formula (above) returns the
count of all unique items in the range

SUM(--(COUNTIF(rngPlaces,rngPlaces)=1))

The 2nd part of the formula (above) returns the
count of unique items which appear only *once* in the range
(This count has to be subtracted from the 1st part of the formula
according to your specs)

So the net return (1st - 2nd) gives the desired result

What is the "--" for in the syntax?


In ... SUM(--(COUNTIF(rngPlaces,rngPlaces)=1))

The "--" is to coerce the TRUE / FALSE returns by the COUNTIF(...)
into 1's and 0's for SUM(...) to return the total

--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----



Bernie Deitrick

Bruce,

Just for completeness - the correct form of my formula to ignore blanks is
to array enter

=SUM(IF(COUNTIF(rngplaces,rngplaces)1,1/COUNTIF(rngplaces,rngplaces),0))

Sorry that I missed that requirement.

HTH,
Bernie
MS Excel MVP


"Bruce Norris" wrote in message
. ..
Oh, that was soooo close, but like Harlan points out, I do have some

blanks
involved. Bummer.

Maybe there's no way to do this with just a formula?



"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Bruce,

Array enter (enter using Ctrl-Shift-Enter)


=SUM(IF(1/COUNTIF(rngPlaces,rngPlaces)<1,1/COUNTIF(rngPlaces,rngPlaces),0))

will work as long as rngPlaces isn't a complete column (must be less

than
65536 cells long)

HTH,
Bernie
MS Excel MVP





"Bruce Norris" wrote in message
.. .
Could someone help me out on this, please?

I have a single column range as a defined name (rngPlaces).

I want a formula in another cell to count how many values (text) appear
more than once in the range.

So...
- Values that appears only once in the list: Don't count.
- Values that appears more than once in the list: Count the value as 1.
- Blank cells: Don't count.

To further clarify - a value that appears multiple times is only
counted once.

- "Mexico City" appears 50 times: "Mexico City" counted as 1
- "Paris" appears 2 times: "Paris" counted as 1
- "Denver" appears 1 time: "Denver" counted as 0

Any ideas?

Excel 2002.

Thanks.










All times are GMT +1. The time now is 09:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com