+ Reply to Thread
Results 1 to 6 of 6

Removing character using Trim..

  1. #1
    Registered User
    Join Date
    04-25-2009
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    84

    Question Removing character using Trim..

    I need your guys expertise in the following formula. I'm applying the following to a large range of data that varies in lenght,however all of the data has a 1Y or 2Y at the end of it. I need to remove it from the data into a new column.

    Currently I'm using =trim(mid(A2,1,30) how can I change my formula to obtain my results?

    for example: Nationwide Select premium $74.99 1Y
    Nationwide Select Premium W/e-mail $74.99 1Y

    As you can see the lenght of the data is different. Thanks in advance for your help.
    Last edited by Jocote46; 05-13-2009 at 01:56 PM.

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

    Re: Removing character using Trim..

    =LEFT((A1),LEN(TRIM(A1))-2)
    note the trim only removes spaces. so

    =left(a1,len(a1)-3)) would probably work as tong as there is a space between end of string and 1y
    Last edited by martindwilson; 05-12-2009 at 05:08 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

  3. #3
    Forum Contributor
    Join Date
    04-01-2009
    Location
    Irvine, CA
    MS-Off Ver
    Excel 2010
    Posts
    280

    Re: Removing character using Trim..

    How about using a nested SUSTITUTE?

    =SUBSTITUTE(SUBSTITUTE(A2," 2Y","")," 1Y","")

    It assumes there is a space before the 2Y or 1Y and that they only occur once in the string.

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,054

    Re: Removing character using Trim..

    How about select -> data -> text to columns -> Delimited -> check By space -> Finish
    Never use Merged Cells in Excel

  5. #5
    Forum Contributor
    Join Date
    10-20-2005
    Posts
    130

    Re: Removing character using Trim..

    How about just replacing 2y & 1y with blank ??
    Regards,
    Little Master

  6. #6
    Registered User
    Join Date
    04-25-2009
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    84

    Talking Re: Removing character using Trim..

    Thank you so much guys, Martin your formula worked great. Thank to the rest for your suggestions. you guys Rock!!

+ 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