+ Reply to Thread
Results 1 to 7 of 7

Extracting Text Between Brackets

  1. #1
    Registered User
    Join Date
    04-04-2009
    Location
    N/A
    MS-Off Ver
    Excel 2003
    Posts
    24

    Extracting Text Between Brackets

    Hi

    I have a column with a series of sentences generated from a server. After the word "Problem" it then gives an error code between square brackets, i.e.

    "Problem in Error [55143] please check in [ABCD]"

    The error codes between square brackets are of diff lengths, and I need to export into a diff column the value between the square brackets AFTER the word "Error" (not the latter one). Is this possible please?

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Extracting Text Between Brackets

    Try:

    =MID(A1,FIND("[",A1)+1,FIND("]",A1)-FIND("[",A1)-1)

    where A1 contains original string.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    04-04-2009
    Location
    N/A
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Extracting Text Between Brackets

    Wow, brilliant! Of course my next question will be, is it possible to extract the second set of square brackets into a diff column please?

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Extracting Text Between Brackets

    Assuming the first formula is in B1, then:

    =MID(SUBSTITUTE(A1,"["&B1&"]",""),FIND("[",SUBSTITUTE(A1,"["&B1&"]",""))+1,FIND("]",SUBSTITUTE(A1,"["&B1&"]",""))-FIND("[",SUBSTITUTE(A1,"["&B1&"]",""))-1)

    or independent of previous result.. and shorter...

    =MID(A1,FIND("^^",SUBSTITUTE(A1,"[","^^",2))+1,FIND("^^",SUBSTITUTE(A1,"]","^^",2))-FIND("^^",SUBSTITUTE(A1,"[","^^",2))-1)
    Last edited by NBVC; 02-04-2010 at 02:10 PM.

  5. #5
    Registered User
    Join Date
    05-17-2016
    Location
    Basel, Switzerland
    MS-Off Ver
    Office 2016
    Posts
    5

    Re: Extracting Text Between Brackets

    Hi,

    I have been able to use these formulas and it perfectly worked. Thanks.

    I'm now looking to update and improve it to match the following requirement, but I did not succeed:

    In my cell, I have the following character string
    Please have a look to (my problem) and to (T+ 12000) and (T+ 12500)

    I would like to export the text inside parenthesis, but only when it starts with T+.

    Thanks

  6. #6
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: Extracting Text Between Brackets

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.

  7. #7
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Extracting Text Between Brackets

    Enter formula in B1 and pull it to C1 and then down
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    v A B C
    1 Problem in Error [55143] please check in [ABCD] 55143 ABCD
    2 Problem in Error [2565897] please check in [ABCD658] 2565897 ABCD658
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

+ 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