+ Reply to Thread
Results 1 to 5 of 5

Remove leading and trailing spaces in a cell?

  1. #1
    Registered User
    Join Date
    04-10-2013
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Remove leading and trailing spaces in a cell?

    Hello,

    I cannot find an answer to this specific question. Does anyone know an easy way to remove all spaces from a cell, both leading and trailing? I find it hard to believe that Excel doesn't have this functionality. I don't particulary want to write a VBA script since I have never done it but if that's the only way, I'd love to know how to write it. I have looked everywhere but obviously not in the right places. Any help would be greatly appreciated!

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Remove leading and trailing spaces in a cell?

    try using =TRIM()
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,704

    Re: Remove leading and trailing spaces in a cell?

    There is a function, TRIM(), which removes leading and trailing spaces, and also multiple spaces between words, so you just need to use:

    =TRIM(A1)

    in a helper column to remove the excess spaces from cell A1. Copy it across and down, as required to remove them from other cells. You can then fix the values in those cells, using Copy | Paste Special | Values | OK and then press the <Esc> key, and then you can paste them over the original values and delete the helper columns.

    Hope this helps.

    Pete

  4. #4
    Registered User
    Join Date
    04-10-2013
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Remove leading and trailing spaces in a cell?

    Thank you so much! Your help is very much appreciated. I saw that function but my attempts to use it failed. Now I know!

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Remove leading and trailing spaces in a cell?

    Happy to help and thanks for the feedback

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Remove leading, trailing & non-breaking spaces on a worksheet
    By Kennethc in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-06-2013, 07:03 PM
  2. insert leading or trailing spaces
    By 2008 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-05-2013, 08:58 PM
  3. [SOLVED] Removing leading and trailing spaces
    By mangesh in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-18-2013, 05:25 AM
  4. [SOLVED] Strip Leading and Trailing Spaces
    By Vladamir in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-19-2012, 03:46 PM
  5. How keep Leading/Trailing spaces when save in Excel?
    By jorgejulio in forum Excel General
    Replies: 0
    Last Post: 08-01-2006, 04:49 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1