Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 46
Default How to count commas in a cell?

Hi Everyone
I have cells with lists of people in them (ie as a list of names, divided by
commas.
I need to count the total number of people in all the cells.
For instance, A1 = Tom, John, Bob
A2 = Kate, Uma, Deidre

I figure if I can count the commas and add 1 to each cell, I'll have the
solution.
But I can't get the count functions to work on a comma (not even as ",")

Could someone point me in the right direction?
Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default How to count commas in a cell?

Try this:

=LEN(A1)-LEN(SUBSTITUTE(A1,",",""))+1

Assumes the cell(s) will not be empty.

--
Biff
Microsoft Excel MVP


"LinLin" wrote in message
...
Hi Everyone
I have cells with lists of people in them (ie as a list of names, divided
by
commas.
I need to count the total number of people in all the cells.
For instance, A1 = Tom, John, Bob
A2 = Kate, Uma, Deidre

I figure if I can count the commas and add 1 to each cell, I'll have the
solution.
But I can't get the count functions to work on a comma (not even as ",")

Could someone point me in the right direction?
Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Max Max is offline
external usenet poster
 
Posts: 9,221
Default How to count commas in a cell?

.. can count the commas

One way
In B1: =LEN(A1)-LEN(SUBSTITUTE(A1,",",""))
Adapt it further to suit your intents,
eg: "+1" to the expression to get the count of names
--
Max
Singapore
http://savefile.com/projects/236895
Downloads:22,500 Files:370 Subscribers:66
xdemechanik
---
"LinLin" wrote:
Hi Everyone
I have cells with lists of people in them (ie as a list of names, divided by
commas.
I need to count the total number of people in all the cells.
For instance, A1 = Tom, John, Bob
A2 = Kate, Uma, Deidre

I figure if I can count the commas and add 1 to each cell, I'll have the
solution.
But I can't get the count functions to work on a comma (not even as ",")


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,934
Default How to count commas in a cell?

This should give you the sum you are after...

=SUMPRODUCT((LEN(A1:A1000)-LEN(SUBSTITUTE(A1:A1000,",",""))+1)*(A1:A1000<"") )

Adjust the ranges to cover the maximum number of rows you expect to have
data in (and make sure you use the same range for each).

--
Rick (MVP - Excel)


"LinLin" wrote in message
...
Hi Everyone
I have cells with lists of people in them (ie as a list of names, divided
by
commas.
I need to count the total number of people in all the cells.
For instance, A1 = Tom, John, Bob
A2 = Kate, Uma, Deidre

I figure if I can count the commas and add 1 to each cell, I'll have the
solution.
But I can't get the count functions to work on a comma (not even as ",")

Could someone point me in the right direction?
Thanks!


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 46
Default How to count commas in a cell?

Thanks Rick - that's saved me a heap of time and I would never have come up
with that!

"Rick Rothstein" wrote:

This should give you the sum you are after...

=SUMPRODUCT((LEN(A1:A1000)-LEN(SUBSTITUTE(A1:A1000,",",""))+1)*(A1:A1000<"") )

Adjust the ranges to cover the maximum number of rows you expect to have
data in (and make sure you use the same range for each).

--
Rick (MVP - Excel)


"LinLin" wrote in message
...
Hi Everyone
I have cells with lists of people in them (ie as a list of names, divided
by
commas.
I need to count the total number of people in all the cells.
For instance, A1 = Tom, John, Bob
A2 = Kate, Uma, Deidre

I figure if I can count the commas and add 1 to each cell, I'll have the
solution.
But I can't get the count functions to work on a comma (not even as ",")

Could someone point me in the right direction?
Thanks!





  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 46
Default How to count commas in a cell?

Thanks Rick - that worked extremely well!

"Rick Rothstein" wrote:

This should give you the sum you are after...

=SUMPRODUCT((LEN(A1:A1000)-LEN(SUBSTITUTE(A1:A1000,",",""))+1)*(A1:A1000<"") )

Adjust the ranges to cover the maximum number of rows you expect to have
data in (and make sure you use the same range for each).

--
Rick (MVP - Excel)


"LinLin" wrote in message
...
Hi Everyone
I have cells with lists of people in them (ie as a list of names, divided
by
commas.
I need to count the total number of people in all the cells.
For instance, A1 = Tom, John, Bob
A2 = Kate, Uma, Deidre

I figure if I can count the commas and add 1 to each cell, I'll have the
solution.
But I can't get the count functions to work on a comma (not even as ",")

Could someone point me in the right direction?
Thanks!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i add commas in a single cell? Footlight Excel Worksheet Functions 2 September 4th 08 08:03 PM
Count the number of Commas found in cell A2 B~O~B Excel Worksheet Functions 3 April 2nd 08 05:27 PM
formula to count commas Janis Excel Discussion (Misc queries) 4 July 19th 07 06:56 PM
Count values between commas jhicsupt Excel Discussion (Misc queries) 4 April 3rd 07 09:13 PM
Count Commas in Cells Dax Arroway Excel Discussion (Misc queries) 5 January 30th 07 08:22 PM


All times are GMT +1. The time now is 05:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"