how to count spaces in a text string

loverfellow

Board Regular
Joined
Mar 4, 2008
Messages
116
I am looking for this for some time. Is there any formula (not vba) to count that how many occurances of spaces are in a text string, spaces could be more than one between the words.
Help me with this please.
 
Last edited:
thanks guys, the problem is solved. It was some kind of junk character which code is 160 while the code of the a normal space is 32. So, this was the text "Mf Offset Paper ", and I finally used this formula which worked fine.
=LEN(A1)-LEN(SUBSTITUTE(A1," ",""))+(LEN(A1)-LEN(SUBSTITUTE(A1," ","")))
 
Upvote 0

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
or this formula meant to work as well.
=LEN(A1)-LEN(SUBSTITUTE(A1,CHAR(160),""))+(LEN(A1)-LEN(SUBSTITUTE(A1," ","")))
 
Upvote 0
Hi loverfellow

It was some kind of junk character which code is 160

For your information, it's the HTML non-breaking space. You usually get it when you copy text from the web.
 
Upvote 0
I think this is the formula that you are looking for.

=SUM(--ISNUMBER(SEARCH(" ",MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1),1)))

press F2 and then ctrl+shift+enter.

i hope it could help :cool:
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,700
Members
448,979
Latest member
DET4492

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top