Count Commas in Cells

G

Guest

I'm looking for a formula that will count commas or count items deliniated by
commas in cells. I've got table data in column A like:

A1=red, blue, green
A2=blue, Fred
A3=Can, jar, stack

And I need to count the elements in each cell. So, after the formula the
cells would list:
B1=2
B2=1
B3=2
(if counting commas) or:
3
2
3
(if counting items)

I then ultimately plan on running a piviot table off of Column B to indicate
by percent of the entries have 1, 2, 3, 4, etc. items listed in them.

Anyone got a way of doing that?

Thanks in advance for your help!
- Dax
 
G

Guest

Try something like this:

With
A1: (containing a comma delimited list)

This formula counts the commas:
=LEN(A1)-LEN(SUBSTITUTE(A1,",",""))

and...this one counts the items
=LEN(A1)-LEN(SUBSTITUTE(A1,",",""))+1

Is that something you can work with?
***********
Regards,
Ron

XL2002, WinXP
 
G

Guest

This formula will give you the number of commas in a cell:

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

And for counting items, just add 1 to the above formula.

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

HTH,
Elkar
 
T

T. Valko

Try this to obtain the count of elements in a cell:

=LEN(A1)-LEN(SUBSTITUTE(A1,",",""))+(A1<>"")

Copy down as needed.

Biff
 
G

Guest

You guys are awesome! Thanks so much!

Ron Coderre said:
Try something like this:

With
A1: (containing a comma delimited list)

This formula counts the commas:
=LEN(A1)-LEN(SUBSTITUTE(A1,",",""))

and...this one counts the items
=LEN(A1)-LEN(SUBSTITUTE(A1,",",""))+1

Is that something you can work with?
***********
Regards,
Ron

XL2002, WinXP
 
G

Guest

You're very welcome....and thanks for the feedback.

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

XL2002, WinXP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

formula to count commas 4
count color cell 2
COUNT 9
COUNTIF formula Using 2 or more cells 2
Add comma after last " in a cell 14
Count max consecutive cells 2
Formula Help 2
Vlookup to count non blank cells 5

Top