Count Characters with space in a cell

G

Guest

Please help...is it a way to count characters with space in a cell?

Examples:
Cell A1: Apple and oranges ==> 17 characters (with spaces); 15 characters
(with no spaces)
Cell A2: Pineapple ==> 9 characters (with and with no spaces)
 
D

Dave Peterson

=len(a1)
will return the count of all characters in A1

=len(substitute(a1," ","")
will count the number of non-spaces in A1

and
=len(a1)-len(substitute(a1," ",""))
will count the number of spaces in A1.
 
D

Dave Peterson

I'd use:
=LEN(A1)-LEN(SUBSTITUTE(A1," ",""))+(A1<>"")

It handles empty cells better.

(and maybe toss in Trim() to make sure extra spaces between words won't cause
errors in the count.)
 

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

Top