+ Reply to Thread
Results 1 to 6 of 6

trim function

  1. #1
    Registered User
    Join Date
    12-09-2008
    Location
    U.S.
    Posts
    15

    trim function

    is there a trim function for numbers?

    i downloaded some data and has leading spaces. trim function does not work, how can i get rid of the spaces with numbers in the cell?

    thank you.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: trim function

    Make sure the cells are not formatted as text. Then select the data and do Data > Text to Columns, Finish.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    12-09-2008
    Location
    U.S.
    Posts
    15

    Re: trim function

    does not seem to work.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,527

    Re: trim function

    The imported data contains spaces and nonprinting (see here for more info).

    As such I've created the following formula which will hopefully do the job - if there is an error (there is no number for instance) a zero is returned:

    =IF(ISERROR(TRIM(SUBSTITUTE(A1,CHAR(160),CHAR(32)))),0,TRIM(SUBSTITUTE(A1,CHAR(160),CHAR(32))))

    HTH

    Robert

  5. #5
    Registered User
    Join Date
    12-09-2008
    Location
    U.S.
    Posts
    15

    Re: trim function

    thank you for your help. however, does not seem to work. i have used the formula and tried doing calculations and all i get is #value.

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: trim function

    The below should work:

    Please Login or Register  to view this content.
    As shg points out however coercing the data is the best solution...

    You can use Edit -> Replace, 2 methods:

    1 - in a blank cell enter =CHAR(160)
    copy that cell, highlight your data, Edit -> Replace:
    Find What: paste your copied cell (will appear as blank but don't worry)
    Replace With: leave empty
    Click Replace All

    2 - if you have a numeric pad available
    Highlight your data, Edit -> Replace:
    Find What: Hold ALT + type in 0160
    Replace With: leave empty
    Click Replace All

    The only non-numerics that would persist from the above process would be the stand alone hyphens... you should not run a replace of the hyphen char (45) if you have negative values in your range as the negatives would thus become positive. However, leaving the stand alone hyphens as text values should not impact on your calcs... ie negatives will have been coerced to number so all numbers can be summed etc...
    Last edited by DonkeyOte; 02-11-2009 at 04:27 AM.

+ 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