+ Reply to Thread
Results 1 to 7 of 7

Splitting multi-line cells into separate rows

  1. #1
    Registered User
    Join Date
    03-25-2008
    Posts
    16

    Splitting multi-line cells into separate rows

    I did a search on "split" but was not able to find a solution for this one.

    I've got a column of names but some of the cells contain multiple - up to 20 - lines of names and I'd like to create another column containing all of those names so that I can de-dupe it and the use it for getting totals from another tab.

    The cells with multiple lines have "#. " in front of the names in a format like this:
    ROW----- CELL DATA
    1-------- OBAMA
    2-------- HILLARY CLINTON
    3-------- MCCAIN
    4-------- 1. OBAMA
    --------- 2. HILLARY CLINTON
    --------- 3. MICKY MOUSE
    5-------- 1. DAFFY DUCK
    --------- 2. MINNIE MOUSE

    So I would like to end up with:

    row-cell data
    1---OBAMA
    2---HILLARY CLINTON
    3---MCCAIN
    4---OBAMA
    5---HILLARY CLINTON
    6---MICKY MOUSE
    7---DAFFY DUCK
    8---MINNIE MOUSE

    Any ideas?
    Thanks for having such a great source of shared info!!

  2. #2
    Valued Forum Contributor
    Join Date
    10-15-2007
    Location
    Home
    MS-Off Ver
    Office 2010, W10
    Posts
    373
    Hi jazzper

    This is easier in vba.

    Assuming the data in column A starting in row 2, the code writes the result in column B, starting in row 2.

    Please Login or Register  to view this content.
    HTH
    lecxe

  3. #3
    Registered User
    Join Date
    03-25-2008
    Posts
    16
    Thanks!!

    I've never done any VBA stuff before but I'm guessing there's instructions on numerous posts here-

  4. #4
    Valued Forum Contributor
    Join Date
    10-15-2007
    Location
    Home
    MS-Off Ver
    Office 2010, W10
    Posts
    373
    I've never done any VBA stuff before but I'm guessing there's instructions on numerous posts here-
    These are step by step instructions to run the code:

    - Activate the vb editor (ALT-F11)

    - Menu Insert>Module (if it's the first module it will be called module1).

    - Paste the code into the module.

    - Click on the code and press F5 or the Run button.

  5. #5
    Registered User
    Join Date
    03-25-2008
    Posts
    16
    Thanks again -- very nice!!

  6. #6
    Registered User
    Join Date
    03-23-2009
    Location
    Mexico
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Splitting multi-line cells into separate rows

    Hello!

    This code was really useful for me too but I need help with the following:

    Supose I have each multi-line cell classified by the cel next to the left, for example:

    Name Multi-Line Cell
    Presidents | Obama, Bush, Clinton
    Countries | USA, France, Canada

    Suppose there was a forced line break after each comma.
    Then I wish the Macro to throw something like this:

    Presidents | Obama
    Presidents | Bush
    Presidents | Clinton

    Countries | USA
    Countries | France
    Countries | Canada

    The code you posted helped me partially but I'm getting nuts trying to deal with the 'for' loops. Any suggestions on how to modify it to achieve these results? Thank you in advance!

  7. #7
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988

    Re: Splitting multi-line cells into separate rows

    G.shima,

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread.

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

+ 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