How to Count the Number of Spaces Before Text String in Excel Cell?


Powerful spreadsheet software like Microsoft Excel provides a number of formulae and tools for manipulating and analysing data. Counting the number of spaces that should come before a certain word or phrase in a cell is a common task when working with text data. In situations when you need to extract specific information or carry out data purification procedures, counting spaces before a text string can be helpful.

This guide will walk you through each step of how to count the spaces that come before a text string in an Excel cell. This article will arm you with the skills you need to complete this work with ease whether you are a novice or seasoned Excel user.

Count the Number of Spaces Before Text String

Here we will get the first value using the formula, then use the autofill handle to complete the task. So let us see a simple process to know how you can count the number of spaces before a text string in an Excel cell.

Step 1

Consider an Excel sheet where you have a list of strings with spaces, similar to the below image.

First, to count the spaces, click on an empty cell and enter the formula as =FIND(LEFT(TRIM(A1),1),A1)-1, and click enter to get the first value.

Empty cell > Formula > Enter.

Step 2

Then, to get all the other values, drag down using the autofill handle from the first value. The final result will be similar to the image below.

This is how you can count the number of spaces before a text string in an Excel cell.

Conclusion

In this tutorial, we have used a simple example to demonstrate how you can count the number of spaces before a text string in an Excel cell to highlight a particular set of data.

Updated on: 21-Aug-2023

895 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements