+ Reply to Thread
Results 1 to 17 of 17

Splitting values within a cell when it contains parentheses without using Text to Columns

  1. #1
    Registered User
    Join Date
    09-15-2021
    Location
    Australia
    MS-Off Ver
    Microsoft Office 365
    Posts
    43

    Splitting values within a cell when it contains parentheses without using Text to Columns

    Hi all,

    I have, what I think may be a simple request where I have a row of data with cells that have values separated by delimiters (parentheses and commas). I would like to split each value into a separate cell. However, I am unable to do this using Text to Columns, because when I split using the comma delimiter, it splits values that I do not want. Please see attached workbook.

    Column A is the original values. The descriptive words (i.e. 'Fields') are separated by numbers in brackets (i.e. 'Percentage'). I would like to split each of these values into separate columns. So Columns B-G will have the separate values. Is there a formula for this?

    Thank you!
    S.
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,255

    Re: Splitting values within a cell when it contains parentheses without using Text to Colu

    In B2 copied across and down:

    =TRIM(MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($A2,"(","|"),")","|"),"|",REPT(" ",LEN($A2))),", ",""),(COLUMNS($A:A)-1)*LEN($A2)+1,LEN($A2)))
    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. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Splitting values within a cell when it contains parentheses without using Text to Colu

    Tricky. Using formulas I think you'll need some helper columns. The alternative is to use a UDF. Both solutions are in the attached.

    WBD
    Attached Files Attached Files
    Office 365 on Windows 11, looking for rep!

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,255

    Re: Splitting values within a cell when it contains parentheses without using Text to Colu

    Can be done without helper columns and without VBA (see post #2).

  5. #5
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Splitting values within a cell when it contains parentheses without using Text to Colu

    Or use the @AliGW solution! Must go and get coffee ...

    WBD

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,255

    Re: Splitting values within a cell when it contains parentheses without using Text to Colu

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

    Also, 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 those who helped.

  7. #7
    Registered User
    Join Date
    09-15-2021
    Location
    Australia
    MS-Off Ver
    Microsoft Office 365
    Posts
    43

    Re: Splitting values within a cell when it contains parentheses without using Text to Colu

    @AliGW

    This works perfectly! I was hoping there would be a more straight-forward and shorter formula, but it looks like it wasn't as 'simple' as I had initially thought. Thank you so much, AliGW!
    Last edited by AliGW; 09-28-2021 at 04:14 AM. Reason: PLEASE don't quote unnecessarily!

  8. #8
    Registered User
    Join Date
    09-15-2021
    Location
    Australia
    MS-Off Ver
    Microsoft Office 365
    Posts
    43

    Re: Splitting values within a cell when it contains parentheses without using Text to Colu

    Quote Originally Posted by WideBoyDixon View Post
    Tricky. Using formulas I think you'll need some helper columns. The alternative is to use a UDF. Both solutions are in the attached.

    WBD
    This also worked exactly how I wanted it! I understand the 'ExtractValue' formula that you have used, but am a little lost with the 'Trim/Mid' formula because I am not familiar with 'helper' columns, but this did the trick regardless! Thanks so much for your help, WideBoyDixon!
    Last edited by Eades1412; 09-28-2021 at 04:24 AM.

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,255

    Re: Splitting values within a cell when it contains parentheses without using Text to Colu

    My formula isn't particularly long.

    Thanks for the rep.

  10. #10
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,016

    Re: Splitting values within a cell when it contains parentheses without using Text to Colu

    FWIW, you could also use:

    =TRANSPOSE(FILTERXML("<x><y>"&SUBSTITUTE(SUBSTITUTE(LEFT(A2,LEN(A2)-1),"(","</y><y>"),"),","</y><y>")&"</y></x>","//y"))

    which will spill across as necessary, then just fill down.
    Everyone who confuses correlation and causation ends up dead.

  11. #11
    Registered User
    Join Date
    09-15-2021
    Location
    Australia
    MS-Off Ver
    Microsoft Office 365
    Posts
    43

    Re: Splitting values within a cell when it contains parentheses without using Text to Colu

    Wow, this is fantastic! I must admit, I am not familiar with this formula at all, but I copy and pasted it, and it worked. Thanks for your suggestion, rorya!
    Last edited by AliGW; 09-28-2021 at 04:28 AM. Reason: PLEASE don't quote unnecessarily!

  12. #12
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Splitting values within a cell when it contains parentheses without using Text to Colu

    How am I seeing FILTERXML for the first time? This is awesome! I'm definitely using this from now on to extract data from text.

    WBD
    Last edited by AliGW; 09-28-2021 at 04:39 AM. Reason: PLEASE don't quote unnecessarily!

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,255

    Re: Splitting values within a cell when it contains parentheses without using Text to Colu

    It's new in 365 - it's something I intend looking into now I'm retired. A fair few experienced members have already got their heads around it!!!

  14. #14
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,016

    Re: Splitting values within a cell when it contains parentheses without using Text to Colu

    There's a good page on it here: https://exceljet.net/excel-functions...erxml-function with some useful examples at the bottom.

  15. #15
    Registered User
    Join Date
    09-15-2021
    Location
    Australia
    MS-Off Ver
    Microsoft Office 365
    Posts
    43

    Re: Splitting values within a cell when it contains parentheses without using Text to Colu

    Thanks for the link to the examples for the FILTERXML function, rorya! This has saved my life! :D

  16. #16
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,255

    Re: Splitting values within a cell when it contains parentheses without using Text to Colu

    @rorya - thank you!

    @Eades112 - saved your life? That's a bit OTT, I'd say!!!

    I'm off to read that article ...

  17. #17
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,544

    Re: Splitting values within a cell when it contains parentheses without using Text to Colu

    Late to the party, but .... Slight variation on a theme, Cell B2, copied down:

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


    Adjust the F$1 if there will be more than six columns to be extracted.

    Based on Rory's article and other examples, and some fine tuning from Rory's formula.
    Last edited by TMS; 09-28-2021 at 06:28 PM.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ 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. Replies: 7
    Last Post: 10-15-2020, 10:38 AM
  2. Extract Text in Parentheses From One Cell to Another
    By Dhyre in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 04-13-2020, 04:10 AM
  3. Splitting text in a single cell across multiple columns
    By gasdesign in forum Excel General
    Replies: 4
    Last Post: 04-03-2016, 03:28 PM
  4. [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
  5. Removing parentheses from text cell
    By Ronno in forum Excel General
    Replies: 4
    Last Post: 01-03-2013, 09:44 AM
  6. Replies: 6
    Last Post: 01-13-2011, 03:00 AM
  7. [SOLVED] Splitting text to columns
    By nospaminlich in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-06-2006, 05:30 PM

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