+ Reply to Thread
Results 1 to 8 of 8

Extracting text from a second set of brackets from a cell to the left.

  1. #1
    Registered User
    Join Date
    02-24-2022
    Location
    Southern England
    MS-Off Ver
    2019
    Posts
    3

    Extracting text from a second set of brackets from a cell to the left.

    I have the formula =TRIM(RIGHT(SUBSTITUTE(SUBSTITUTE(B2, ")",""),"(",REPT(" ",99)),99))
    which aims extract text from a second set of brackets in a cell, however my brackets in the cell are [ ] not (). What do I need to change about the above to make this work for my brackets please

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

    Re: Extracting text from a second set of brackets from a cell to the left.

    Welcome to the forum.

    Assuming you mean that BOTH sets of brackets are square ones:

    =TRIM(RIGHT(SUBSTITUTE(SUBSTITUTE(B2, "]",""),"[",REPT(" ",99)),99))

    If not, then there are instructions at the top of the page explaining how to attach your sample workbook.

    A good sample workbook has just 10-20 rows of representative data that has been desensitised. It also has expected results mocked up, relevant cells highlighted and a few explanatory notes.
    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.

  3. #3
    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,099

    Re: Extracting text from a second set of brackets from a cell to the left.

    FILTERXML is also a greta way of parsing complex strings:


    =FILTERXML("<A><B>"&SUBSTITUTE(SUBSTITUTE(B2,"[","</B><B>",2),"]","</B><B>",2)&"</B></A>","//B[2]")

    again, assiuming both sets of parentheses are square
    Attached Files Attached Files
    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

  4. #4
    Registered User
    Join Date
    02-24-2022
    Location
    Southern England
    MS-Off Ver
    2019
    Posts
    3

    Re: Extracting text from a second set of brackets from a cell to the left.

    Thank you so much for the welcome and your expertise.
    The formula worked very well, however, it is also extracting the text that follows the second sett of bracketed text. For example the result can look like this:
    CIRET [3pc] PREMIER SYNTHETIC BRUSH SET [15060310] 1x25,1x38,1x50mm (result) 15060310 1x25,1x38,1x50mm
    How do I alter the formula to stop it extracting text following the desired extract.
    Any further help would be greatly appreciated.

    Regards
    Angus

  5. #5
    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,099

    Re: Extracting text from a second set of brackets from a cell to the left.

    As I said... FILTERXML is very powerful. It works on your data.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    02-24-2022
    Location
    Southern England
    MS-Off Ver
    2019
    Posts
    3

    Re: Extracting text from a second set of brackets from a cell to the left.

    Thank you very much Glenn. This also works well. Your help is very much appreciated.
    Angus

  7. #7
    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
    81,233

    Re: Extracting text from a second set of brackets from a cell to the left.

    The formula worked very well, however, it is also extracting the text that follows the second sett of bracketed text.
    Next time provide some sample data (15-20 rows of it) with worked examples of what you want.

    I answered your question based on the information you gave in the opening post. As you didn't disclose anything more, I did not anticipate there being anything more to take into consideration.

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

    Also, if you have not already done so, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.

  8. #8
    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,099

    Re: Extracting text from a second set of brackets from a cell to the left.

    I'm not sure about the "as well" bit... as it did NOT return the subsequent, unwanted data... but whatever!

    You're welcome.



    It would be very nice if you were to just click the Add Reputation button at the foot of any of the posts of members who helped you reach a solution.

    Finally, if that takes care of your original question, please select "Thread Tools" from the menu link (just above the first post in the thread) and mark this thread as SOLVED.

+ 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. Formula to remove Brackets and Text in brackets
    By jshaw82 in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 06-27-2022, 09:41 AM
  2. Extracting Text Between Brackets
    By McNulty in forum Excel General
    Replies: 6
    Last Post: 05-17-2016, 07:16 PM
  3. [SOLVED] Extracting data from between brackets in a cell
    By Gooford in forum Excel General
    Replies: 4
    Last Post: 07-31-2014, 04:36 PM
  4. [SOLVED] Extracting multiple text within brackets
    By guapo in forum Excel General
    Replies: 10
    Last Post: 12-18-2012, 08:19 PM
  5. extracting text left of second hyphen
    By nikoelnutto in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-11-2012, 10:44 AM
  6. Excel 2007 : Extracting text from within brackets
    By EMarky in forum Excel General
    Replies: 5
    Last Post: 08-09-2010, 03:50 PM
  7. Extracting Text from a string of text between brackets
    By easty in forum Excel - New Users/Basics
    Replies: 11
    Last Post: 12-02-2009, 11:29 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