+ Reply to Thread
Results 1 to 7 of 7

Splitting mullti-line cells into separate rows and repeat values in columnA after split

  1. #1
    Registered User
    Join Date
    07-18-2012
    Location
    NJ
    MS-Off Ver
    Excel 2010
    Posts
    9

    Splitting mullti-line cells into separate rows and repeat values in columnA after split

    I have an excel doc with a few columns, some of them contain several lines per cell.
    I need to convert them into columns where each row contains single line.
    I column A is Name which has to be repeated after split.
    Sometimes in columnA is only Name and I need to keep this row.

    Example
    Name1| Tra1 |Date1 |Rat1
    | Tra2 |Date2 |Rat1
    Name2| | |
    Name3|Tra3 |Date3 |Rat3
    |Tra4 |Date4 |
    |Tra5 |Date5 |Rat5

    Name1 is one row with 2 lines in the cells
    Name3 is one row with 3 lines in the cells

    Output (each row has only 1 line):

    Name1|Tra1 |Date1 |Rat1
    Name1|Tra2 |Date2 |Rat1
    Name2| | |
    Name3|Tra3 |Date3 |Rat3
    Name3|Tra4 |Date4 |
    Name3|Tra5 |Date5 |Rat5
    I have attached a file with the data.

    Any suggestions ?
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Re: Splitting mullti-line cells into separate rows and repeat values in columnA after spli

    Copy code to a standard module.
    Run: SplittingMultiLineCellsIntoSeparateRows

    Please Login or Register  to view this content.

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Splitting mullti-line cells into separate rows and repeat values in columnA after spli

    try
    Please Login or Register  to view this content.
    ExampleWithCode.xlsm

  4. #4
    Registered User
    Join Date
    07-18-2012
    Location
    NJ
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Splitting mullti-line cells into separate rows and repeat values in columnA after spli

    @ StevenM
    Thank you so much! It works. I really appreciate it.
    Last edited by Cutter; 07-30-2012 at 01:40 PM. Reason: Removed whole post quote

  5. #5
    Registered User
    Join Date
    07-18-2012
    Location
    NJ
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Splitting mullti-line cells into separate rows and repeat values in columnA after spli

    Hi Jindon,
    Thanks for the code. It worked on the spreadsheet I've attached as an example but when I used the real data I got an error 13 'Type mismatch' on line txt = Join$(Application.Transpose(.Columns("b").Value)).
    I am attaching the file.
    I was wondering why I got error 13.
    Thanks again for the help. I really appreciate it.
    Attached Files Attached Files

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Splitting mullti-line cells into separate rows and repeat values in columnA after spli

    Ah, Transpose function will not work when any cell has over 255 characters...

    How about
    ExampleWithCode2.xlsm

  7. #7
    Registered User
    Join Date
    07-18-2012
    Location
    NJ
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Splitting mullti-line cells into separate rows and repeat values in columnA after spli

    Thanks a lot! I appreciate your help.
    Thanks again & Best Regards
    Last edited by Cutter; 07-30-2012 at 01:41 PM. Reason: Removed whole post quote

+ 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