How To remove leading spaces from text in Excel
Method 1: Using the TRIM Function
The TRIM
function removes all extra spaces (including leading and trailing spaces) from text.
-
Enter Data:
- Suppose your data is in Column
A
(e.g.,A1:A10
).
- Suppose your data is in Column
-
Use the TRIM Function:
-
In a new column (e.g., Column
B
), type the following formula:=TRIM(A1)
-
Press Enter. This removes leading (and extra) spaces for the text in
A1
.
-
-
Copy the Formula Down:
- Drag the fill handle (small square in the bottom-right corner of the selected cell) down to apply the formula to other rows.
-
Replace Original Data (Optional):
- Copy the cleaned data from Column
B
. - Right-click on Column
A
→ Select Paste Special → Choose Values.
- Copy the cleaned data from Column
-
Delete the Helper Column:
- Once done, you can delete Column
B
.
- Once done, you can delete Column
Method 2: Using Text-to-Columns
If spaces only appear at the beginning (leading spaces), this method works well.
-
Select Your Data:
- Highlight the column containing the data with spaces.
-
Go to Text-to-Columns:
- On the Data tab, click Text to Columns.
-
Select Delimited:
- Choose the Delimited option → Click Next.
-
Remove All Delimiters:
- Ensure no delimiter options (like Tab, Comma) are selected → Click Next.
-
Set Column Data Format:
- Select General as the column data format → Click Finish.
This removes leading spaces from the selected cells.
Method 3: Find and Replace
-
Select Your Data:
- Highlight the column or range of cells.
-
Open Find and Replace:
- Press Ctrl + H to open the Find and Replace window.
-
Set Up Find and Replace:
- Find what: Type a single space ( ).
- Replace with: Leave it blank.
- Click Replace All.