3 Ways to Remove Leading, Trailing, & Extra Spaces in Excel

Download Article
Use Find & Replace and simple formulas to clean up your Excel data
Download Article

Sometimes importing data into Microsoft Excel from an external source can add extra spaces to your cell values. This can really mess with your formulas! If your cells are plagued with random spaces between numbers, leading and trailing spaces, and multiple spaces between words, don't worry—there are easy ways to fix your data. This How.com.vn article will teach you how to remove spaces between numbers and characters, as well as from before and after values, in your Excel spreadsheet.

Things You Should Know

  • To remove spaces between numbers and words, press Ctrl + H, press the Spacebar in the "Find what" field, then click "Replace all."
  • You can also use the SUBSTITUTE function to remove extra space between characters.
  • To remove extra space from the beginning or end of a value, use the TRIM function.
Method 1
Method 1 of 3:

Using Find and Replace

Download Article
  1. How.com.vn English: Step 1 Highlight the range where you want to remove all spaces.
    For example, if you want to remove spaces from C2 through C30, highlight those cells.
    • This method removes any extra spaces between numbers, words, and other characters. To eliminate leading and trailing spaces, see Using the TRIM Function.
    • This method will not delete extra space at the beginning or end of the value, just spaces between characters.
  2. How.com.vn English: Step 2 Press Ctrl+H to...
    Press Ctrl+H to open Find and Replace. This quick keyboard shortcut works on both Windows and macOS.[1]
    Advertisement
  3. Step 3 Click the box next to "Find What."
  4. How.com.vn English: Step 4 Press the space bar on the keyboard.
    Make sure to press it only once. This adds a space to the "Find what" field.
  5. How.com.vn English: Step 5 Click Replace All.
    It's the second button at the bottom of the window. This searches for all spaces between numbers and other characters in the selected range and deletes them.
    • A pop-up will show how many spaces were removed. Click "'OK'" on the pop-up to return to your worksheet.
  6. Advertisement
Method 2
Method 2 of 3:

Using the SUBSTITUTE Function

Download Article
  1. How.com.vn English: Step 1 Click the top cell in a blank column.
    To remove extra space between numbers, characters, or words in a cell, you can use the SUBSTITUTE function. Click a cell on the same row as the first cell in the column with the extra spaces.
    • For example, if you want to remove spaces from column A, and A's first row of data is in row 1 (A1), click the first cell in your blank column (e.g., B1, C1, D1, etc.).
  2. How.com.vn English: Step 2 Type =SUBSTITUTE into the cell.
  3. How.com.vn English: Step 3 Click the first cell in the column with spaces.
    For example, if the first cell in the column that has extra spaces is A1, click it now.
    • If you clicked cell A1, the formula should now look like this: =SUBSTITUTE(A1 .
  4. How.com.vn English: Step 4 Type , (a comma).
    The cell should now look like this: =Substitute(A1,.
  5. Step 5 Type " ",.
    That's a double quotation mark, a space, another double quotation mark, and then a comma. There's a space between the two sets of double quotes—this is important.
    • The formula should now look like this: =SUBSTITUTE(A1," ",.
  6. Step 6 Type ""
    . This time, there's NO space between the sets of quotes.
    • The formula should now look like this: =SUBSTITUTE(A1," ","".
  7. How.com.vn English: Step 7 Type a closed parenthesis ) and press ↵ Enter or ⏎ Return.
    In the end, the formula should now read =SUBSTITUTE(A1," ",""). You will now see the contents of the selected cell (A1, in this example) without spaces in the new column.[2]
    • For example, if C2 said w ww . wikih ow .com, your new cell will say www.wikihow.com.
  8. How.com.vn English: Step 8 Apply the changes to the entire column.
    The easiest way to do this is to use Autofill:
    • Click the cell into which you typed the formula to select it.
    • Double-click the square at the bottom-right corner of the box.
    • Alternatively, drag the square down until you've reached the bottom of the column.
    • You can now easily copy the new column without spaces and paste it into the original column. Your new space-free data is now in place.
  9. Advertisement
Method 3
Method 3 of 3:

Using the TRIM Function

Download Article
  1. How.com.vn English: Step 1 Click the top cell in a blank column.
    The TRIM function removes extra spaces from the beginning and end of a cell's value. It will also remove extra space (except for single spaces) between words.[3] Click the first cell on the same row as the first line of data in the column with the extra spaces.
  2. How.com.vn English: Step 2 Type =TRIM( into the cell.
  3. How.com.vn English: Step 3 Click the first cell that contains extra spaces.
    This adds the cell address to the TRIM formula.
    • For example, if you click A1, your formula should now look like this: =TRIM(A1
  4. How.com.vn English: Step 4 Type a closed parenthesis ) and press ↵ Enter or Return.
    Your ending formula should look like this: =TRIM(A1). This removes any excess spaces at the beginning or end of the selected cell. It will also remove extra space between words "except" for single spaces.
  5. How.com.vn English: Step 5 Apply the changes to the entire column.
    The easiest way to do this is to use Autofill:
    • Click the cell into which you typed the formula to select it.
    • Double-click the square at the bottom-right corner of the box.
    • Alternatively, drag the square down until you've reached the bottom of the column.
    • You can now easily copy the new column without extra space and paste it into the original column. Your new space-free data is now in place.
  6. Advertisement

Expert Q&A

Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
      Advertisement

      Video

      Tips

      Submit a Tip
      All tip submissions are carefully reviewed before being published
      Thanks for submitting a tip for review!
      Advertisement

      About This Article

      How.com.vn English: Nicole Levine, MFA
      Written by:
      How.com.vn Technology Writer
      This article was co-authored by How.com.vn staff writer, Nicole Levine, MFA. Nicole Levine is a Technology Writer and Editor for How.com.vn. She has more than 20 years of experience creating technical documentation and leading support teams at major web hosting and software companies. Nicole also holds an MFA in Creative Writing from Portland State University and teaches composition, fiction-writing, and zine-making at various institutions. This article has been viewed 103,639 times.
      How helpful is this?
      Co-authors: 4
      Updated: April 1, 2024
      Views: 103,639
      Categories: Microsoft Excel
      Thanks to all authors for creating a page that has been read 103,639 times.

      Is this article up to date?

      ⚠️ Disclaimer:

      Content from Wiki How English language website. Text is available under the Creative Commons Attribution-Share Alike License; additional terms may apply.
      Wiki How does not encourage the violation of any laws, and cannot be responsible for any violations of such laws, should you link to this domain, or use, reproduce, or republish the information contained herein.

      Notices:
      • - A few of these subjects are frequently censored by educational, governmental, corporate, parental and other filtering schemes.
      • - Some articles may contain names, images, artworks or descriptions of events that some cultures restrict access to
      • - Please note: Wiki How does not give you opinion about the law, or advice about medical. If you need specific advice (for example, medical, legal, financial or risk management), please seek a professional who is licensed or knowledgeable in that area.
      • - Readers should not judge the importance of topics based on their coverage on Wiki How, nor think a topic is important just because it is the subject of a Wiki article.

      Advertisement