+ Reply to Thread
Results 1 to 10 of 10

Trim cell results

  1. #1
    Registered User
    Join Date
    01-15-2010
    Location
    Scottsdale
    MS-Off Ver
    Excel 2010
    Posts
    72

    Trim cell results

    I have a data download from SAP. The format the data comes into excel is with 8 spaces then the data. I would like to trim the 8 spaces to only 4. Is there a function like Trim() but that only trims a selected amount of spaces?

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: How do you trim cell results

    You could do something like

    =right(A1,len(A1)-4)

    or

    Please Login or Register  to view this content.
    cheers

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: How do you trim cell results

    or
    =rept(" ",4)&trim(a1)
    Last edited by martindwilson; 07-19-2010 at 06:54 PM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  4. #4
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: How do you trim cell results

    Try this
    Please Login or Register  to view this content.

    Or more precisely
    Please Login or Register  to view this content.

    N.B.
    Char(32) = "Space "


    Hope this helps
    Last edited by Marcol; 07-19-2010 at 07:02 PM.
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  5. #5
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: How do you trim cell results

    =SUBSTITUTE(TRIM(A1)," ",REPT(" ",4)) wont work as once trimmed a1 has no spaces
    but here,s another
    =REPLACE(A1,1,4,"")
    Last edited by martindwilson; 07-19-2010 at 07:05 PM.

  6. #6
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: How do you trim cell results

    Hmm .... martindwilson

    I disagree, seems to work for me.

    The second alternative is less error prone.

    [EDIT]
    Might be the difference between Trim in Excel and VBa
    VBa removes leading and trailing spaces
    Excel Formula removes all excess spaces
    Last edited by Marcol; 07-19-2010 at 07:17 PM.

  7. #7
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: How do you trim cell results

    wanna bet? lol
    Attached Files Attached Files

  8. #8
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: How do you trim cell results

    Hi martin

    I re-read the question and you are correct, I assumed the spaces were within the string.

    My apologies......

    Why should anyone want leading spaces?.....

  9. #9
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: How do you trim cell results

    ......................................................................ah now there's a thing! oops blast those spaces lol

  10. #10
    Registered User
    Join Date
    01-15-2010
    Location
    Scottsdale
    MS-Off Ver
    Excel 2010
    Posts
    72

    Re: How do you trim cell results

    Thanks for the responses all. I dont would rather not have the leading spaces, but don't want to rebuild the whole model that someone else have created either.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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