+ Reply to Thread
Results 1 to 11 of 11

trim does not remove leading spaces?

  1. #1
    Registered User
    Join Date
    11-09-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2007
    Posts
    12

    trim does not remove leading spaces?

    I have a column of text, some having leading spaces. I must remove all leading spaces.
    I have tried =trim(cell), but it does not remove them. I then tried
    =trim(clean(cell)) thinking that there might be some unprintables lurking.
    That also does not work. I can manually remove the leading spaces, so I can see them [or the lack of them], but Excel does not seem to be able to work as needed.
    Am I doing something wrong? It seems Trim should work.

    I would MOST appreciate any thoughts or solutions.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,433

    Re: trim does not remove leading spaces?

    Try copying one of the characters, then deselecting the cell and doing a Replace All, pasting the character you just copied. Possibly CHAR(160)


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: trim does not remove leading spaces?

    If it is CHAR(160), give this a try
    Please Login or Register  to view this content.
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  4. #4
    Registered User
    Join Date
    11-09-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: trim does not remove leading spaces?

    TMS, I don't think I understood your suggestion correctly. I am far from an Excel expert. But, gmr, your suggestion worked! That strips what I suppose is char(160) away, leaving exactly what I need

    THANK YOU BOTH!

  5. #5
    Registered User
    Join Date
    11-09-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: trim does not remove leading spaces?

    TMS, I don't think I understood your suggestion correctly. I am far from an Excel expert. But, gmr, your suggestion worked! That strips what I suppose is char(160) away, leaving exactly what I need

    THANK YOU BOTH!

    (how do I mark this as solved?)

  6. #6
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: trim does not remove leading spaces?

    You're welcome
    To mark as solved:
    -Go to the top of the first post
    -Select Thread Tools
    -Select Mark thread as Solved

  7. #7
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: trim does not remove leading spaces?

    TMS deserves some credit for this as well. Had he not mentioned CHAR(160) in his post, it wouldn't have clicked with me what the problem was.

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,433

    Re: trim does not remove leading spaces?

    @gmr4evr1: thanks. inventorgeorge has already +repped me, although I suspect that your solution made his progress quicker. All good

  9. #9
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: trim does not remove leading spaces?

    If you need to do this frequently the macro at this website
    will remove all leading/trailing and multiple interspersed
    char 32 space characters. It will also remove and/or convert
    char 160 non breaking spaces into standard char 32 space
    characters.
    It will work on text or numbers and the numbers will be
    converted to true numeric numbers.

    I use this macro dozens of times every single day!
    It's a real time saver.

    http://www.mvps.org/dmcritchie/excel/join.htm#trimall
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  10. #10
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: trim does not remove leading spaces?

    Thanks for the info Tony.

  11. #11
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: trim does not remove leading spaces?

    You're welcome!

+ 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 Spaces, Trim?
    By cybercab in forum Excel General
    Replies: 3
    Last Post: 02-11-2023, 02:39 PM
  2. How to remove leading spaces
    By Terressa in forum Excel General
    Replies: 4
    Last Post: 06-27-2015, 07:45 PM
  3. TRIM function and leading spaces
    By nsv in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 10-01-2014, 10:32 PM
  4. Delete Trailing Spaces without Removing leading zeros WITHOUT TRIM
    By Zach51215 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-20-2013, 04:24 PM
  5. trim leading spaces
    By captain bob in forum Excel General
    Replies: 2
    Last Post: 08-03-2006, 10:00 AM
  6. trim leading spaces
    By [email protected] in forum Excel General
    Replies: 10
    Last Post: 05-11-2006, 04:25 PM
  7. [SOLVED] VBA help please - remove leading spaces
    By Scott Wagner in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-24-2006, 04:20 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