+ Reply to Thread
Results 1 to 13 of 13

Split Cell with multiple delimiters into multiple rows and columns

  1. #1
    Forum Contributor
    Join Date
    12-29-2012
    Location
    usa
    MS-Off Ver
    Excel 2016
    Posts
    325

    Split Cell with multiple delimiters into multiple rows and columns

    So I have a cell that looks like this:

    Dog; 1, Cat; 2, Bird; 6, Pig; 4

    I would like to dump all the animal names (items that come before the ";") into one column and in the column next to it dump all the numbers (items that come before the ","). So in the end it would look something like this:
    Column A Column B
    Dog 1
    Cat 2
    Bird 6
    Pig 4

    I've done splits before but not with multiple delimiters?

  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. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,324

    Re: Split Cell with multiple delimiters into multiple rows and columns

    You can do this with two steps in PowerQuery:

    1. Split column to rows using ; as the delimiter.
    2. Split column to columns using , as the delimiter.

    EDIT: Other way round!
    Last edited by AliGW; 07-03-2019 at 09:22 AM.
    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 Contributor
    Join Date
    12-29-2012
    Location
    usa
    MS-Off Ver
    Excel 2016
    Posts
    325

    Re: Split Cell with multiple delimiters into multiple rows and columns

    Hi Ali, that's a good solution but I think I need something VBA - based to solve this issue.
    Last edited by AliGW; 07-03-2019 at 09:18 AM. Reason: Please don't quote unnecessarily!

  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. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,324

    Re: Split Cell with multiple delimiters into multiple rows and columns

    Why does it have to be VBA?

  5. #5
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Question

    Quote Originally Posted by nobodyukno View Post
    So I have a cell that looks like this:

    Dog; 1, Cat; 2, Bird; 6, Pig; 4
    So we don't know which is the cell ? Its address will help us to elaborate an easy way …

  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. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,324

    Re: Split Cell with multiple delimiters into multiple rows and columns

    Here's the PQ M Code:

    Please Login or Register  to view this content.
    The result:

    Excel 2016 (Windows) 32 bit
    A
    B
    1
    Column1.1 Column1.2
    2
    Dog
    1
    3
    Cat
    2
    4
    Bird
    6
    5
    Pig
    4
    Sheet: Sheet2
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    12-29-2012
    Location
    usa
    MS-Off Ver
    Excel 2016
    Posts
    325

    Re: Split Cell with multiple delimiters into multiple rows and columns

    Quote Originally Posted by Marc L View Post
    So we don't know which is the cell ? Its address will help us to elaborate an easy way …
    The cell would be L1 but I can always adjust

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

    Re: Split Cell with multiple delimiters into multiple rows and columns

    Set the source and target cell as necessary:

    Please Login or Register  to view this content.
    WBD
    Office 365 on Windows 11, looking for rep!

  9. #9
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool

    Quote Originally Posted by nobodyukno View Post
    The cell would be L1 but I can always adjust
    In an Excel worksheet array the comma separates columns and the semicolon separates rows
    but your data in L1 is exactly the opposite so just with the VBA Replace function
    that's easy just with a couple of codelines like this beginner starter demonstration :

    PHP Code: 
    Sub Demo()
        
    Dim V
            V 
    Evaluate("{""" Replace$(Replace$([L1].Text"; """","), ", "";""") & "}")
            [
    A1].Resize(UBound(V), UBound(V2)).Value2 V
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !
    Last edited by Marc L; 07-03-2019 at 07:22 PM. Reason: typo …

  10. #10
    Forum Contributor
    Join Date
    12-29-2012
    Location
    usa
    MS-Off Ver
    Excel 2016
    Posts
    325

    Re: Split Cell with multiple delimiters into multiple rows and columns

    Quote Originally Posted by WideBoyDixon View Post
    Set the source and target cell as necessary:

    Please Login or Register  to view this content.
    WBD
    Quote Originally Posted by Marc L View Post
    In an Excel worksheet array the comma separates columns and the semi column separates rows
    but your data in L1 is exactly the opposite so just with the VBA Replace function
    that's easy just with a couple of codelines like this beginner starter demonstration :

    PHP Code: 
    Sub Demo()
        
    Dim V
            V 
    Evaluate("{""" Replace$(Replace$([L1].Text"; """","), ", "";""") & "}")
            [
    A1].Resize(UBound(V), UBound(V2)).Value2 V
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !
    Both work! Thanks a lot!

  11. #11
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Thumbs up

    You're welcome and thanks for the rep' !

  12. #12
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    MS365 V.2406
    Posts
    2,308

    Re: Split Cell with multiple delimiters into multiple rows and columns

    Another way...
    Please Login or Register  to view this content.

  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. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,324

    Re: Split Cell with multiple delimiters into multiple rows and columns

    Thanks foe the rep.

+ 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: 04-29-2016, 12:25 AM
  2. Replies: 1
    Last Post: 01-15-2016, 09:59 AM
  3. Split multiple Delimiter field with Header into Multiple Columns and Rows
    By omershafiq2012 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-27-2015, 08:01 AM
  4. Split text into array using multiple delimiters
    By TKFRMjarvis in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-26-2014, 03:07 PM
  5. split multiple semicolon separated values into new rows for multiple columns
    By bruno08102013 in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 01-05-2014, 05:27 PM
  6. [SOLVED] Separating data with multiple delimiters into columns AND rows
    By CALALOO722 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-09-2013, 08:13 AM
  7. Replies: 1
    Last Post: 01-17-2006, 08:10 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