ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   number of spaces... (https://www.excelbanter.com/excel-worksheet-functions/114795-number-spaces.html)

Mark

number of spaces...
 
Hello.

I know someone showed me this before, but I've forgotten.

If I wanted to do a count of the number of spaces within a single cell, how
could I do that?

For instance, if I wanted to look at a cell that contained 'A B C D', and
get the answer that there are three spaces in that.

Thanks.
Mark

Bernard Liengme

number of spaces...
 
=LEN(A1)-LEN(SUBSTITUTE(A1," ",""))
best wishes
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"mark" wrote in message
...
Hello.

I know someone showed me this before, but I've forgotten.

If I wanted to do a count of the number of spaces within a single cell,
how
could I do that?

For instance, if I wanted to look at a cell that contained 'A B C D', and
get the answer that there are three spaces in that.

Thanks.
Mark




Dave Peterson

number of spaces...
 
=(len(a1)-len(substitute(a1," ","")))/len(" ")

Since you're only counting a single character, you could eliminate the
denominator:

=len(a1)-len(substitute(a1," ",""))



mark wrote:

Hello.

I know someone showed me this before, but I've forgotten.

If I wanted to do a count of the number of spaces within a single cell, how
could I do that?

For instance, if I wanted to look at a cell that contained 'A B C D', and
get the answer that there are three spaces in that.

Thanks.
Mark


--

Dave Peterson


All times are GMT +1. The time now is 01:32 PM.

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