+ Reply to Thread
Results 1 to 17 of 17

Modification to very useful text trim formula

  1. #1
    Registered User
    Join Date
    08-30-2017
    Location
    UK
    MS-Off Ver
    2010
    Posts
    6

    Modification to very useful text trim formula

    Hi,

    I found this formula online somewhere (very cool as it is) but could someone modify it so that it does not include the search term in the result?

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    For info:
    by varying X and Y the formula extracts specific parts of a text string

    Using it on: aaaaX123Yaaaa
    would give: X123

    I would like it to return: 123

    Thanks if you can help

  2. #2
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Modification to very useful text trim formula

    Welcome to the forum Morph1ne.

    Maybe

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Dave

  3. #3
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Modification to very useful text trim formula

    Or this.

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  4. #4
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Modification to very useful text trim formula

    Sorry I didn't read the "varying" part carefully. Put the varying items in B1:C1 and replace by reference.

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-30-2017
    Location
    UK
    MS-Off Ver
    2010
    Posts
    6

    Re: Modification to very useful text trim formula

    Dave

    thanks (not sure where X and Y went in your second post!!)

    I cant get your formulas to work, maybe I oversimplified my example?

    With the original formula I can use "M" and "\" to get MH.123 from QL-A\PMH.123\PFWIC

    But I would like to get 123

  6. #6
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Modification to very useful text trim formula

    Try the formula in post #3. Since you want only the numbers that formula extracts numbers only. There is no need for substitutions.


    A
    B
    C
    1
    aaaaX123Yaaaa
    123
    In B1: =SUMPRODUCT(MID(0&A1,LARGE(INDEX(ISNUMBER(--MID(A1,ROW($1:$30),1))*ROW($1:$30)+1,0),ROW($1:$30)),1)*10^ROW($1:$30)/10)
    Last edited by FlameRetired; 08-30-2017 at 02:08 PM.

  7. #7
    Registered User
    Join Date
    08-30-2017
    Location
    UK
    MS-Off Ver
    2010
    Posts
    6

    Re: Modification to very useful text trim formula

    I did oversimplify

    a text example: QL-A\PMH.1\PFWIC\PCL=94.07\PIL=90.43\PSF=0.33d\P{\C24;Assumed To Be Clay Pipes}

    so the formula in post #3 extracts 19407

    not sure why #4 wont work with . and \ in B1 and C1 though?

  8. #8
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Modification to very useful text trim formula

    OK this is a much different problem.

    With QL-A\PMH.1\PFWIC\PCL=94.07\PIL=90.43\PSF=0.33d\P{\C24;Assumed To Be Clay Pipes} what do you want returned? There are several numbers.

  9. #9
    Registered User
    Join Date
    08-30-2017
    Location
    UK
    MS-Off Ver
    2010
    Posts
    6

    Re: Modification to very useful text trim formula

    In this case 1!

    but it would be useful to extract any number between specific characters

  10. #10
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Modification to very useful text trim formula

    Here are two examples with "boundary" texts in columns B:C


    A
    B
    C
    D
    E
    1
    QL-A\PMH.1\PFWIC\PCL=94.07\PIL=90.43\PSF=0.33d\P{\C24;Assumed To Be Clay Pipes}
    .
    \
    1
    In D1: =--TRIM(LEFT(SUBSTITUTE(MID(A1,FIND(B1,A1)+1,99),C1,REPT(" ",99)),99))
    2
    QL-A\PMH.1\PFWIC\PCL=94.07\PIL=90.43\PSF=0.33d\P{\C24;Assumed To Be Clay Pipes}
    =
    \
    94.07

  11. #11
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,063

    Re: Modification to very useful text trim formula

    We are suffering from unrepresentative data here. Please post an excel sheet with CLEAR before/after positions.


    Unfortunately the attachment icon doesn't work at the moment. So, to attach an Excel file you have to do the following: Just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  12. #12
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,063

    Re: Modification to very useful text trim formula

    ... or going back to your original Q... does this work???

    =TRIM(LEFT(SUBSTITUTE(MID(A1,FIND("X",A1)+1,LEN(A1)),"Y",REPT(" ",100)),100))

  13. #13
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Modification to very useful text trim formula

    What Glenn says.

    If you would post an Excel workbook (not pics or screenshots ... saves retyping data)

    Include about 10-20 examples. Provide a mix of the strings you will be working with.

    If you are not familiar with how to do this:

    To attach a file to your post,
    • be sure to desensitize the data
    • click “Go Advanced” (next to Post Quick Reply – bottom right),
    • scroll down until you see “Manage Attachments”, click that,
    • click “Browse”.
    • select your file(s)
    • click “Upload”
    • click “Close window”
    • click “Submit Reply”

    The file name will appear at the bottom of your reply.

  14. #14
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,063

    Re: Modification to very useful text trim formula

    Another shot in the dark..... Is this what you want?????


    =TRIM(LOOKUP(99^99,--("0"&MID(A1,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"0123456789")),ROW(1:10000)))))

    assumes data in A1 and it returns 1 from:

    QL-A\PMH.1\PFWIC\PCL=94.07\PIL=90.43\PSF=0.33d\P{\C24;Assumed To Be Clay Pipes}

  15. #15
    Registered User
    Join Date
    08-30-2017
    Location
    UK
    MS-Off Ver
    2010
    Posts
    6

    Re: Modification to very useful text trim formula

    Hi,
    yes I should have been more specific! but this is a typical example of the text strings:

    QL-A\PMH.1\PFWIC\PCL=94.07\PIL=90.43\PSF=0.33d\P{\C24;Assumed To Be Clay Pipes}

    I am ok to modify a formula to contain specific search terms as in my original example

    Search > Returns
    MH. > 1
    CL= > 94.07
    IL= > 90.43

    thanks again

  16. #16
    Registered User
    Join Date
    08-30-2017
    Location
    UK
    MS-Off Ver
    2010
    Posts
    6

    Re: Modification to very useful text trim formula

    Quote Originally Posted by Glenn Kennedy View Post
    ... or going back to your original Q... does this work???

    =TRIM(LEFT(SUBSTITUTE(MID(A1,FIND("X",A1)+1,LEN(A1)),"Y",REPT(" ",100)),100))
    OK that's good, I can vary + as appropriate!!

  17. #17
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Modification to very useful text trim formula

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

+ 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 text
    By isameer247 in forum Excel General
    Replies: 5
    Last Post: 02-26-2015, 03:43 AM
  2. Formula to trim text with spaces
    By nickm84 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-07-2013, 06:45 AM
  3. [SOLVED] Trim text
    By rizmomin in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-19-2013, 11:18 AM
  4. [SOLVED] Slight Modification Request VBA Code - Text File to Excel
    By spiwere in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 03-22-2013, 04:39 AM
  5. Little modification for trimming text vba
    By Zaeguzah in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-13-2010, 07:47 AM
  6. text modification
    By jtaiariol in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-17-2005, 09:35 AM
  7. Urgent !!! Macro for Number to Text Modification
    By shashidharga in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-20-2005, 11:56 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