+ Reply to Thread
Results 1 to 13 of 13

Removing Extra Space in Copied Data

  1. #1
    Registered User
    Join Date
    10-02-2009
    Location
    Arlington, VA, USA
    MS-Off Ver
    Excel 2003
    Posts
    34

    Removing Extra Space in Copied Data

    I copied a bunch of economic data and I am trying to do calculations with it. Only problem is that the original source contained extra spaces, so Excel doesn't recognize the data as numbers.

    For instance, instead of "9.9", it would be "9.9 " with the extra space. All the data in my spreadsheet is like this.

    Is there any way to correct this all at once, without manually deleting spaces in the spreadsheet?

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Removing Extra Space in Copied Data

    In a helper column you could use =Trim(A1)
    HTH
    Regards, Jeff

  3. #3
    Registered User
    Join Date
    10-02-2009
    Location
    Arlington, VA, USA
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: Removing Extra Space in Copied Data

    Quote Originally Posted by jeffreybrown View Post
    In a helper column you could use =Trim(A1)
    TRIM doesn't seem to work for whatever reason. Not sure if there's something odd about the data.

    I also tried VALUE and that didn't seem to work.

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Removing Extra Space in Copied Data

    Okay, maybe try...

    =TRIM(CLEAN(SUBSTITUTE(A1,CHAR(160)," ")))

    http://www.rondebruin.nl/clean.htm

  5. #5
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Removing Extra Space in Copied Data

    There is some sort of other invisible character there. Things to try
    =CLEAN(A1)

    or =CODE(RIGHT(A1,1)) that will tell us what invisible character it is (i.e. 32 = space)

    Then
    =(SUBSTITUTE(A1,CHAR(32),""))+0
    Or
    Do a search replace by copying that invisibile character into the replace field and replace it with nothing.
    Any of these work for you?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  6. #6
    Registered User
    Join Date
    10-02-2009
    Location
    Arlington, VA, USA
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: Removing Extra Space in Copied Data

    Wow, this is one annoying set of data!

    Both of the below failed to work:

    =TRIM(CLEAN(SUBSTITUTE(A1,CHAR(160)," ")))
    =CLEAN(A1)

    The third one:

    =CODE(RIGHT(A1,1))

    Gives me a result of "160". What does that mean?


    I also tried the replacing method earlier and couldn't get it to work.

    I'm not sure what is up with this data.

  7. #7
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Removing Extra Space in Copied Data

    Do you have a small sample workbook you can attach?

  8. #8
    Registered User
    Join Date
    10-02-2009
    Location
    Arlington, VA, USA
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: Removing Extra Space in Copied Data

    Here's a spreadsheet with one page of the data.


    Note that the only way I've been able to fix it thus far is to manually delete the space in every cell. I'm not sure why that would work, but none of the formulas would work to do the same thing.
    Last edited by Jakila2; 06-28-2011 at 05:29 PM.

  9. #9
    Registered User
    Join Date
    10-02-2009
    Location
    Arlington, VA, USA
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: Removing Extra Space in Copied Data

    Actually, looks like I might have changed the data slightly in that spreadsheet. I experimented with custom formatting a bit.

    This edit eliminates that. (Though, it shouldn't alter things significantly anyway).
    Attached Files Attached Files

  10. #10
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Removing Extra Space in Copied Data

    This worked for me...

    =TRIM(CLEAN(SUBSTITUTE(B3,CHAR(160)," ")))

    Check out the attachment. I put a column for before which shows a length of 4 and then after the formula, a length of 3.
    Attached Files Attached Files

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

    Re: Removing Extra Space in Copied Data

    you have char 160 at the end of each cell
    select all then find replace alt+0160 with nothing
    nb you must use the num keypad to enter 0160
    here it is done
    Attached Files Attached Files
    Last edited by martindwilson; 06-28-2011 at 05:32 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

  12. #12
    Registered User
    Join Date
    10-02-2009
    Location
    Arlington, VA, USA
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: Removing Extra Space in Copied Data

    Thanks a bunch, Jeff.

    Actually, looks like it worked the first time. I only thought it didn't because the alignment was exactly the same on mine. When I delete the space manually, it aligns to the right.

    Sorry about that. My mistake there.
    Last edited by Jakila2; 06-28-2011 at 05:44 PM.

  13. #13
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Removing Extra Space in Copied Data

    Not a problem...just glad you got it working

+ 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