Closed Thread
Results 1 to 15 of 15

Extract Text in Parentheses From One Cell to Another

  1. #1
    Registered User
    Join Date
    03-23-2015
    Location
    USA
    MS-Off Ver
    2013
    Posts
    7

    Extract Text in Parentheses From One Cell to Another

    I am needing to extract some text in parentheses in one cell and move it to another cell. The data all starts with a description, some text in the first set of parentheses, then some more text in another set of parentheses. Some cells of data only have one set of parentheses and others have two sets of parentheses. All have varying numbers of chracters within the first and second set of parentheses. I am trying to write a formula to only extract the data in the second set of parentheses, (always the parentheses to the far right) excluding the parentheses to move to another cell.

    Examples:

    Epoxy Pavement Marking (Low VOC Solvent Base) (0200-627-00012 - PVMNT)
    Striping Mobilization (0185-62600000 - MOB)

    Desired Results:
    Example #1: B12: Epoxy Pavement Marking (Low VOC Solvent Base) C12: 0200-627-00012 - PVMNT
    Example #2: B13: Striping Mobilzation C13: 0185-62600000 - MOB

    My data in the spreadsheet always starts with B12, if that helps to write the specific formula.

    Thanks in advance for the help....

  2. #2
    Forum Contributor
    Join Date
    06-21-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    191

    Re: Extract Text in Parentheses From One Cell to Another

    This will work for B12, assuming your data is in A1:
    =LEFT(A1,FIND("(",A1,FIND("(",A1)+1)-2)

    C12, also assuming the data is A1:
    =MID(A1,FIND("(",A1,FIND("(",A1)+1)+1,LEN(A1)-FIND("(",A1,FIND("(",A1)+1)-1)

    EDIT:
    Just realized that only works when there's a second set of parentheses. Same principal applies, though, to only a single set of parentheses. You can add an if statement, I suppose, to determine the number of parenthetical statements to use the correct formula.
    Last edited by soberguy; 03-23-2015 at 01:45 PM.

  3. #3
    Registered User
    Join Date
    03-23-2015
    Location
    USA
    MS-Off Ver
    2013
    Posts
    7

    Re: Extract Text in Parentheses From One Cell to Another

    Thanks for the reponse, my data is actually starting in B12, but I changed the formula to reflect that. Either way, I want the result to move to C12, (no problem if it needs to be split to C12 and D12) Both formulas are giving me the "#VALUE!" error. I was expecting the formula to start from the right and move to the left looking for the first set of parentheses and moving or copying that data.

    Any ideas?

  4. #4
    Forum Contributor
    Join Date
    06-21-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    191

    Re: Extract Text in Parentheses From One Cell to Another

    Apparently you didn't catch the edit.

    Column C:
    IF(LEN(B12)-LEN(SUBSTITUTE(B12,"(",""))=1,LEFT(B12,FIND("(",B12)-2),LEFT(B12,FIND("(",B12,FIND("(",B12)+1)-2))

    This should work for column D:
    =IF(LEN(B12)-LEN(SUBSTITUTE(B12,"(",""))=1,MID(B12,FIND("(",B12)+1,FIND(")",B12)-FIND("(",B12)-1),MID(B12,FIND("(",B12,FIND("(",B12)+1)+1,LEN(B12)-FIND("(",B12,FIND("(",B12)+1)-1))

  5. #5
    Registered User
    Join Date
    03-23-2015
    Location
    USA
    MS-Off Ver
    2013
    Posts
    7

    Re: Extract Text in Parentheses From One Cell to Another

    Ah ha, I did not catch the edit. Fantastic, that worked great. Thanks for the help.

  6. #6
    Registered User
    Join Date
    03-23-2015
    Location
    USA
    MS-Off Ver
    2013
    Posts
    7

    Re: Extract Text in Parentheses From One Cell to Another

    In using the formula provided yesterday the formulas worked great but in testing it with my data I have ran into a few issues. In some rows of data I was mistaking by saying there are sometimes only one set of parentheses and other times two sets. There are sometimes three and four sets of parentheses. The data I am needng to extract and move to the adjacent cell is always in the far right parentheses. Would it be possible to write the formula to look from the right and move to the left, moving the data in the first set? Also, the other issue I am having is that some of my lines of data do not have parentheses at all. In this scenario, the result from the current formula written is giving me "#VALUE!" in both cells. Would it be possible to include some sort of an "If" statement to solve this problem?

  7. #7
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Extract Text in Parentheses From One Cell to Another

    Hi.

    Perhaps you could give some more realistic examples, then, together with your expected results.

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  8. #8
    Registered User
    Join Date
    03-23-2015
    Location
    USA
    MS-Off Ver
    2013
    Posts
    7

    Re: Extract Text in Parentheses From One Cell to Another

    Below are some examples of the data that gets dumped from another program and the variables I am running into:

    Cell B12: 2" MILLING
    Cell B13: Rem Pavement Marking (0015 - 202-00250 - Rem...)
    Cell B14: Pvmt Mkg Paint (Low VOC Solvent Base) (0210 - 627-00012 - Pvm...)
    Cell B15: Preform Plastic Pvmt Mkg (Ty II)(Inlaid) (0220 - 627-02010 - Pre...)

    Desired Result:

    Cell B12: 2" MILLING Cell C12: *BLANK*, or a #VALUE! would be fine, but I need the data to remain in B12
    Cell B13: Rem Pavement Marking Cell C13: 0015 - 202-00250 - Rem...
    Cell B14: Pvmt Mkg Paint (Low VOC Solvent Base) Cell C14: 0210 - 627-00012 - Pvm...
    Cell B15: Preform Plastic Pvmt Mkg (Ty II)(Inlaid) Cell C15: 0220 - 627-02010 - Pre...


    From these cells, I am trying to extract the data from just the far right set of parentheses, excluding the parentheses themselves into another cell using a formula. As you can see from the examples, not all of the data has parentheses, some have one set of parentheses, some have two sets, and others have three sets. Fortunately the the data does always have the same number of characters if that helps.

    Thank you in advance.

  9. #9
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Extract Text in Parentheses From One Cell to Another

    Thanks.

    In all of your examples there is never any further text after the desired extraction. I assume then that this is always the case?

    Regards

  10. #10
    Registered User
    Join Date
    03-23-2015
    Location
    USA
    MS-Off Ver
    2013
    Posts
    7

    Re: Extract Text in Parentheses From One Cell to Another

    That is exactly right. There is never any further text after the desired data I am trying to extract, the program I am dumping the data from always abreviates as shown and there is never another set of parentheses or any other data to the right.

  11. #11
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Extract Text in Parentheses From One Cell to Another

    Perhaps an array formula**:

    =IF(COUNTIF(B12,"*)*"),SUBSTITUTE(MID(B12,1+MATCH(1,0/(MID(B12,ROW(INDEX(A:A,1):INDEX(A:A,LEN(B12))),1)="(")),LEN(B12)),")",""),"")

    Regards


    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).

  12. #12
    Registered User
    Join Date
    03-23-2015
    Location
    USA
    MS-Off Ver
    2013
    Posts
    7

    Re: Extract Text in Parentheses From One Cell to Another

    That worked perfect as far as copying the correct information to the designated cells. Can this be done to then remove the data and set of parentheses I copied from the original cells? This formula left the original data in B12, B13, and so on....

  13. #13
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Extract Text in Parentheses From One Cell to Another

    You can then use (in e.g. D12):

    =SUBSTITUTE(B12,"("&C12&")","")

    Actually, I think this non-array formula, although a bit longer, may be a touch more efficient than the version I posted previously:

    =IF(COUNTIF(B12,"*)*"),SUBSTITUTE(MID(B12,1+FIND("ζ",SUBSTITUTE(B12,"(","ζ",LEN(B12)-LEN(SUBSTITUTE(B12,"(","")))),LEN(B12)),")",""),"")

    Regards

  14. #14
    Registered User
    Join Date
    09-20-2010
    Location
    islamabad
    MS-Off Ver
    Excel 2019
    Posts
    83

    Re: Extract Text in Parentheses From One Cell to Another

    I have similar question what aboout if a cell does not contain parentheses but the next cell contains it , can i place two checkes in excel that if parantehsis is present extract what is inside ,if parantheis is not there copy the noraml text i want to define two conditions how i can do it my formula for extracting parentheses is working as follows but if skips the cell which dont have parentheses and the row becomes empty

    =IFERROR(MID(Z2, SEARCH("(", Z2)+1, SEARCH(")",Z2)-SEARCH("(",Z2)-1),"")

    Also I have another formula in another column to check two subnets if any IP falls unders that range it display type as Fortinet VPN , I want to keep this condition +above together with a third condition in excel to generate the result

    =IF(OR(ISNUMBER(SEARCH("10.179.26",Z2)),ISNUMBER(SEARCH("10.179.27",Z2))),"Fortinet VPN","")

    can you guys help ?

  15. #15
    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,918

    Re: Extract Text in Parentheses From One Cell to Another

    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    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.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Need to get stock symbols from a webpage directly
    By the duke in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-28-2014, 04:36 PM
  2. [SOLVED] Extracting all text from parentheses (including parentheses)
    By j4ke101 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 05-10-2013, 08:03 AM
  3. Extracting text within a parentheses
    By mridul1984 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-15-2013, 02:11 AM
  4. Removing parentheses from text cell
    By Ronno in forum Excel General
    Replies: 4
    Last Post: 01-03-2013, 09:44 AM
  5. Replies: 6
    Last Post: 01-13-2011, 03:00 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