+ Reply to Thread
Results 1 to 3 of 3

Remove trailing space from a cell, convert to number

  1. #1
    Registered User
    Join Date
    05-10-2005
    MS-Off Ver
    Office 2007 & 2010
    Posts
    67

    Remove trailing space from a cell, convert to number

    My apologies if this has been posted already but I have not been able to find a thread like this yet.

    At the office we use a third party program that we can export data into excel (csv) format which we then copy into a worksheet "machine" of sorts. They have recently changed the format of one of the columns in the export. In column D starting on row 3 are values with a space at the end. These values are "general" format, so how the space is present after a number is beyond me. The values in column D contain both numbers and letters (examples: 602, 677A, ....) there are also three digit single numbers (002) that can be displayed as 2 when we are done. Also the number of entries in column D can vary. May be 100s or 1,000's of lines. The current project has 4850+.

    What I am looking for is a macro that will remove the space from the end of the values in D and leave them as a general format. If the 002 returns to 2 it will be alright.

    I imagine it is pretty simple but I am far from a macro/vba guru.

    As an updated note I did try to just find and replace a space with nothing but, excel was unable to find a "space" at the end, even tho if you use the len() function on a cell showing 602, the formula will return 4.

    Any help will be much appreciated!

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

    Re: Remove trailing space from a cell, convert to number

    I suspect =CODE(RIGHT(D3)) returns 160 ?

    Regardless, if you always need to replace the last char then perhaps:

    Please Login or Register  to view this content.
    Modify sheet name as appropriate.

  3. #3
    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: Remove trailing space from a cell, convert to number

    Try this in a spare column

    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    Drag/Fill down

    Copy the result.
    Select D3
    Paste Special > Values

    Also see here

    http://office.microsoft.com/en-us/ex...003056131.aspx

    Hope this helps
    Last edited by Marcol; 08-20-2010 at 12:31 PM. Reason: Added formula to return a number
    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.

+ 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