+ Reply to Thread
Results 1 to 6 of 6

Strange Space in field

  1. #1
    Registered User
    Join Date
    01-17-2011
    Location
    Stoke-ontrent
    MS-Off Ver
    Excel 2010
    Posts
    25

    Strange Space in field

    Hello All

    I am trying to create a macro to remove a space at the end of my text/numbers. I have used

    Please Login or Register  to view this content.
    This works perfectly for everything except when I want it to find the space at the end of my characters.

    I've copied and pasted the "character" in between the quatation marks to find but it just brings up a question mark.

    does anyone know what this character is or how to remove it?

    I've attached a file with an example of what i have in A1

    It's driving me crazy as it's the last part of my macro and it will make life easy for my staff.

    Thank you in advance

    Mod's note: Code tags added for you...this time
    Attached Files Attached Files
    Last edited by FDibbins; 05-02-2013 at 11:41 AM.

  2. #2
    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,879

    Re: Strange Space in field

    Hi and welcome to the forum

    please use code tags when posting VBA code, see my notes below on how to
    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

  3. #3
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: Strange Space in field

    Untested

    Please Login or Register  to view this content.
    Perhaps it was the Noid who should have avoided me...
    If you are satisfied with my solution click the small star icon on the left. Thanks
    1. Make a copy of your workbook and run the following code on your copy (just in case)
    2. With excel open, press ALT+F11 to open the Visual Basic Editor (VBE). From the "Insert" menu, select "Module".
    3. Paste the code from above into the empty white space. Close the VBE.
    4. From the developer tab, choose "Macros", select the Sub Name, and click "Run".

  4. #4
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: Strange Space in field

    ^ The Execl worksheetfunction for trim works differently than the VBA version, so the above will not work. Instead, try:

    Please Login or Register  to view this content.
    Let us know if this works

  5. #5
    Registered User
    Join Date
    01-17-2011
    Location
    Stoke-ontrent
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: Strange Space in field

    Hi apologies for putting missing the code rules.

    I'm quite new to VBA

    I've created a new sub and put the trim code in and it does nothing when I run the macro over the selected data.

  6. #6
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: Strange Space in field

    Hi Chay,

    I just ran the following code on your test file and it worked. Let me know if it works for you.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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