How to count the number of spaces of text string in Excel?
Have you ever tried to count the number of spaces of text string in a cell? Of course, you can count them one by one manually, but, if there are multiple cells needed to be counted, this way will be tedious and time consuming. Today, I can talk about some formulas for dealing with this problem in Excel.
Count the number of spaces or other special characters：
Kutools for Excel’s Countchar function can help you quickly count the number of specific character appears in a cell.
Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download and free trial Now!
To get the number of all spaces among the text string, the following formula can help you, please do as this:
1. Enter this formula: =LEN(A2)-LEN(SUBSTITUTE(A2," ",""))(A2 contains the text string that you want to count the spaces) into a blank cell, see screenshot:
And then drag the fill handle over to the cells which you want to apply this formula, and all the spaces of a cell have been counted as follows:
If you have Kutools for Excel, its COUNTCHAR function of Kutools Functions may help you quickly count the number of times a specific character (such as a specific letter, comma, space and so on) appears within a cell.
|Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no limitation in 60 days.|
After installing Kutools for Excel, please do as follows:
1. Click a cell where you want to put the result, B2, for example.
2. Then click Kutools > Kutools Function > Statistical & Math > COUNTCHAR, see screenshot:
3. In the Function Arguments dialog box, click button from the Within_text to select the cell that you want to get the number of the spaces, and then type the space bar once in the Find_text box, see screenshot:
4. Then click OK button, you will get the number of spaces in the text string, and then drag the fill handle down to the cells which you want to apply this formula, all the spaces among the text strings have been counted at once. See screenshot:
The above formula can help you to count all spaces among the text string, but, if you just need to count the leading spaces of text string, I can introduce you another formula.
1. Please type this formula: =FIND(LEFT(TRIM(A2),1),A2)-1 (A2 contains the text string that you want to count the spaces) into a blank cell, see screenshot:
2. Then drag the fill handle over to the range that you want to contain this formula, and then all the leading spaces before the text string have been counted, see screenshot:
Recommended Productivity Tools
Bring handy tabs to Excel and other Office software, just like Chrome, Firefox and new Internet Explorer.
Amazing! Increase your productivity in 5 minutes. Don't need any special skills, save two hours every day!
300 New Features for Excel, Make Excel Much Easy and Powerful:
- Merge Cell/Rows/Columns without Losing Data.
- Combine and Consolidate Multiple Sheets and Workbooks.
- Compare Ranges, Copy Multiple Ranges, Convert Text to Date, Unit and Currency Conversion.
- Count by Colors, Paging Subtotals, Advanced Sort and Super Filter,
- More Select/Insert/Delete/Text/Format/Link/Comment/Workbooks/Worksheets Tools...