+ Reply to Thread
Results 1 to 15 of 15

Remove spaces in pasted numbers

  1. #1
    Forum Contributor
    Join Date
    05-09-2013
    Location
    Berlin/Sweden
    MS-Off Ver
    Excel 2010
    Posts
    124

    Remove spaces in pasted numbers

    I have pasted a large range of values - slightly inconvenient these values contain spaces, like this:

    104 232
    97 122
    89 396
    87 247

    Since its numbers the substitute function doesn't work. Any suggestions how to crack this?

    Thanks.
    Last edited by Jonathan9; 01-14-2014 at 01:10 PM.

  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,464

    Re: Remove spaces in pasted numbers

    Since its numbers the substitute function doesn't work.

    Sure it does:
    Formula: copy to clipboard
    Please Login or Register  to view this content.




    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 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,464

    Re: Remove spaces in pasted numbers

    I note that you have been active on the forum since this solution was posted. Please let me know if it resolves your issue.


    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

  4. #4
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,499

    Re: Remove spaces in pasted numbers

    BTW, I would also think find and replace would work, it did when I tried it.
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  5. #5
    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,464

    Re: Remove spaces in pasted numbers

    @Sambo kid: absolutely, no reason why not ... and leaves real numbers. I was just addressing the assertion that "the substitute function doesn't work."


    Regards, TMS

  6. #6
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,499

    Re: Remove spaces in pasted numbers

    Sure, got it. I'm sure it didn't slip your mind, just thought I'd mention it to the OP. BTW, I wondered why you had the two dashes in front of the formula, I had success w/substitute w/o them, then I tried it with them and saw it formatted as # instead of text. Cool.
    That's why I like this forum, I always learn stuff... thx.

  7. #7
    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,464

    Re: Remove spaces in pasted numbers

    @Sambo kid: yes, use a double negative to coerce a text number into a real number. Or, you can multiply by 1, or you can add 0

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Not a lot in it, more a matter of personal taste. Note that they ALL fail if the cell is empty or contains spaces. SO you'd need an IFERROR to cater for that.


    Regards, TMS
    Last edited by TMS; 01-14-2014 at 09:05 AM.

  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,464

    Re: Remove spaces in pasted numbers

    @Sambo kid: thanks for the feedback and rep.

  9. #9
    Forum Contributor
    Join Date
    05-09-2013
    Location
    Berlin/Sweden
    MS-Off Ver
    Excel 2010
    Posts
    124

    Re: Remove spaces in pasted numbers

    Thanks for the reply!

    Unfortunately it didn't work. For some reason I get Error in value. However, if I just write in a cell and then do the --substitute formula then it works. So it's something fishy about the pasted values. I ran clean, trim and repasted as values but it still won't work for some reason.

  10. #10
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,499

    Re: Remove spaces in pasted numbers

    you referring to my recommendation about find "space" and replace all "" or TMS's rec?

  11. #11
    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,939

    Re: Remove spaces in pasted numbers

    It might help if you provided a sample workbook showing what you are working with?
    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

  12. #12
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Remove spaces in pasted numbers

    Try this

    =--SUBSTITUTE(A2,CHAR(160),"")
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  13. #13
    Forum Contributor
    Join Date
    05-09-2013
    Location
    Berlin/Sweden
    MS-Off Ver
    Excel 2010
    Posts
    124

    Re: Remove spaces in pasted numbers

    Quote Originally Posted by AlKey View Post
    Try this

    =--SUBSTITUTE(A2,CHAR(160),"")
    Ahaa! Success. That worked. Thanks

    Would you mind elaborating on the CHAR(160) part of the formula? Just so I can understand how it works.
    Last edited by Jonathan9; 01-14-2014 at 01:08 PM.

  14. #14
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Remove spaces in pasted numbers

    I think Find/Replace should works

    Ctrl-H
    Find what":<hit space bar>
    Replace with: <leave it blank>
    Quang PT

  15. #15
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Remove spaces in pasted numbers

    Quote Originally Posted by Jonathan9 View Post
    Ahaa! Success. That worked. Thanks

    Would you mind elaborating on the CHAR(160) part of the formula? Just so I can understand how it works.
    160 is a NON-BREAKING HTML SPACE character. It can't be removed by trim or substitute regular space.


    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. [SOLVED] Remove part of pasted information in cells?
    By Vihral in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 12-19-2012, 12:57 PM
  2. [SOLVED] remove spaces (special characters) after numbers
    By fareastwarriors in forum Excel General
    Replies: 13
    Last Post: 11-04-2012, 09:25 PM
  3. [SOLVED] Excel 2007 : Function to remove spaces in telephone numbers
    By benoj2005 in forum Excel General
    Replies: 6
    Last Post: 06-27-2012, 06:16 AM
  4. Replies: 3
    Last Post: 04-05-2012, 01:20 PM
  5. How to remove hidden grapics from copied web page pasted in Excel.
    By Crake in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-24-2005, 01:06 AM

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