+ Reply to Thread
Results 1 to 16 of 16

Multi-line excel cells into rows

  1. #1
    Registered User
    Join Date
    08-03-2012
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    8

    Multi-line excel cells into rows

    Hi,

    I have three columns which contain multi-line cells, i.e. text separated by ALT+ENTER. Lines of these cells are grouped with each other, i.e. line 1 in cell A2 match with line 1 in B2 and C2. Then I have columns from onwards which have info in the first line which is attributable to all lines in the specific row.

    I now want to turn these multi-line cells from columns A to C to multiple rows and copy the data of columns D to onwards to every new row.

    Hopefully my explanation was not too complicated.

    -Valt
    Last edited by walimos; 08-03-2012 at 09:19 AM.

  2. #2
    Registered User
    Join Date
    08-03-2012
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Multi-line excel cells into rows

    Previous data deleted.
    Last edited by walimos; 08-04-2012 at 03:48 AM.

  3. #3
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Multi-line excel cells into rows

    Is this data attached in post 2 containing real information? It looks so. In that case, please remove it and attach a new file with dummy data.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  4. #4
    Registered User
    Join Date
    08-03-2012
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Multi-line excel cells into rows

    Pls find dummy sheet and desired output sheet enclosed.
    Attached Files Attached Files

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

    Re: Multi-line excel cells into rows

    try
    Please Login or Register  to view this content.

  6. #6
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Multi-line excel cells into rows

    This should work

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    08-03-2012
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Multi-line excel cells into rows

    jindon & mike7952,

    Thank you for your help. I'm still very beginner with Macros. How do I have to adjust the equation/macro if I want to increase the number of rows and columns in my excel sheet. In my actual data set my data expands up to column CL (which of columns A to F have multi-line data) and up to row 11550, number of lines within one column being max 54.

    I just try to understand what are the lines which I have to modify.

  8. #8
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Multi-line excel cells into rows

    Can you upload you workbook?

  9. #9
    Registered User
    Join Date
    08-03-2012
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Multi-line excel cells into rows

    Pls find extract of it enclosed. Unfortunately the whole file is too big to be uploaded.
    Attached Files Attached Files

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

    Re: Multi-line excel cells into rows

    try this
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    08-03-2012
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Multi-line excel cells into rows

    Thnx Jindon,

    It works perfectly with the extract file but gives error when I try to run it with the whole data. Any idea what could be the reason. Error message / bug seems to be in the last row of the code " Sheets("result").Cells(1).Resize(n, UBound(b, 2)).Value = b"

    ---------- Post added at 10:38 AM ---------- Previous post was at 10:35 AM ----------

    'Run-time error '9': Subscript out of range' is the error code.

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

    Re: Multi-line excel cells into rows

    Quote Originally Posted by walimos View Post

    'Run-time error '9': Subscript out of range' is the error code.
    It seems the code doesn't find the sheet named "result"...

    Do you actually see the added sheet named result?

  13. #13
    Registered User
    Join Date
    08-03-2012
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Multi-line excel cells into rows

    Yes I do. But nothing in it.

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

    Re: Multi-line excel cells into rows

    Do you have actually have sheet named "ActiveSheet"?

  15. #15
    Registered User
    Join Date
    08-03-2012
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Multi-line excel cells into rows

    No I didn't have it. It seemed to solve the problem and works like a champ now. Thank you for your help jindon. You saved my day.

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

    Re: Multi-line excel cells into rows

    OK, no problem.

+ 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