Is it possible to count a text string inside a cell

Posted on

QUESTION :

In Excel 2003, is it possible to count the number of commas in a cell containing the text.
For example cell A1 contains the text
a,b,c,d,e,f,
In cell A2 I would like to display the number of commas present in A1, that is 6

ANSWER :

You could use a formula like this:

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

This gets the length of A1, then takes A1 and removes all the commas, and returns the difference. In your case, 6.

Leave a Reply

Your email address will not be published. Required fields are marked *