+ Reply to Thread
Results 1 to 7 of 7

Need formual to trim off all after the 2nd letter L

  1. #1
    Forum Contributor
    Join Date
    08-14-2012
    Location
    USA
    MS-Off Ver
    Excel 2007, MS 365 (Windows 10 Pro 64-bit)
    Posts
    810

    Need formual to trim off all after the 2nd letter L

    Hi,
    Please help me with formula how to trim the number after the 2nd letter L:

    BEFORE
    C33:L36
    C52:L56L60
    C71:L76L83L90
    C103:L123L128L133L145

    AFTER
    C33:L36
    C52:L56
    C71:L76
    C103:L123

    Regards,
    tt3
    Last edited by tuongtu3; 03-22-2020 at 02:10 AM. Reason: SOLVED

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,947

    Re: Need formual to trim off all after the 2nd letter L

    For values starting in A2:

    =IFERROR(LEFT(A2,FIND("L",A2,FIND("L",A2)+1)-1),A2)
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Need formual to trim off all after the 2nd letter L

    Try, with your text in A2,
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Forum Contributor
    Join Date
    08-14-2012
    Location
    USA
    MS-Off Ver
    Excel 2007, MS 365 (Windows 10 Pro 64-bit)
    Posts
    810

    Re: Need formual to trim off all after the 2nd letter L

    Hi,
    The two formula work great but I want the result is blank if cell is blank. Please help me

    Regards,
    tt3

  5. #5
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,947

    Re: Need formual to trim off all after the 2nd letter L

    =if(a2="","",iferror(left(a2,find("l",a2,find("l",a2)+1)-1),a2))

  6. #6
    Forum Contributor
    Join Date
    08-14-2012
    Location
    USA
    MS-Off Ver
    Excel 2007, MS 365 (Windows 10 Pro 64-bit)
    Posts
    810

    Re: Need formual to trim off all after the 2nd letter L

    Hi Bernie,
    Thank for your help

    Regards,
    tt3

  7. #7
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,416

    Re: Need formual to trim off all after the 2nd letter L

    Quote Originally Posted by Bernie Deitrick View Post
    =if(a2="","",iferror(left(a2,find("l",a2,find("l",a2)+1)-1),a2))
    I know this thread has been marked SOLVED, but I thought I would point out that your formula can be simplified like this...

    =LEFT(A2,SEARCH("L",A2&"LL",SEARCH("L",A2&"L")+1)-1)

    Note 1: I used SEARCH instead of FIND because the OP used upper case "L" in Message #1 but said your formula worked using lower case "L" in the FIND function. Since I was not sure what case the "L" actually is, I simply used SEARCH so it does matter. If the "L" is always upper case, the OP can replace my SEARCH functions with FIND if desired.

    Note 2: The key being able to eliminate the IFERROR and test for "" is simply making sure the SEARCH (or FIND) function always has an "L" to find.
    Last edited by Rick Rothstein; 03-22-2020 at 04:19 AM.

+ 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] trim to match two sets of input-trim spaces around a character
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-21-2017, 12:33 PM
  2. VLOOKUP + TRIM, TRIM Lookup table array...
    By mangesh.mehendale in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 10-19-2016, 02:10 AM
  3. [SOLVED] Formual to Trim String
    By rizmomin in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-22-2014, 10:13 PM
  4. [SOLVED] VBA TRIM is won't TRIM active worksheet
    By Groovicles in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 06-06-2014, 09:55 AM
  5. Trying to trim a trailing space char and the Trim function isn't working
    By Psychochook in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-30-2007, 11:28 PM
  6. Trim rightword letter in a word
    By amag in forum Excel General
    Replies: 1
    Last Post: 12-16-2005, 07:15 AM
  7. [SOLVED] VBA Trim and Application.worksheetfunction.Trim
    By Hari Prasadh in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-19-2005, 11: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