+ Reply to Thread
Results 1 to 4 of 4

Trying to trim a trailing space char and the Trim function isn't working

  1. #1
    Registered User
    Join Date
    10-16-2007
    Posts
    4

    Trying to trim a trailing space char and the Trim function isn't working

    Hi,

    I am having trouble trimming a trailing space from a string that I have extracted from a cell as part of a macro.

    I have looked at different options and the one that seems to be the best is the Trim function, in particular, the RTrim. Here is the code that I have written
    Please Login or Register  to view this content.
    The string values in the cells very in length from 2 to 4 chars (eg EF or ABDC) but always have 1 space at the end. In some cases there are spaces inside the string value (eg ST F or E F) and I need to keep those spaces.

    When I run the above code, for the first messagebox I might get "BALT ." then the second message box appears with "BALT ." (exactly the same).

    Anyone got any suggestions as to how I can do this?

    Thanks

    Simon
    Last edited by VBA Noob; 10-31-2007 at 03:44 AM.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,474
    Maybe This would work
    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Simon

    It may not be a trailing space, but some other "non printing" character.

    Try using the CLEAN function instead of the RTRIM function and see if that gets rid of it.


    rylo

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

    It may not necessarily be a space but a nonprinting character.

    Try using this...

    Please Login or Register  to view this content.
    ...instead of

    Please Login or Register  to view this content.
    If the problems persists, see if this formula does the trick.

    HTH

    Robert

+ 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