+ Reply to Thread
Results 1 to 6 of 6

To convert cells with break lines into multiple rows and columns

  1. #1
    Registered User
    Join Date
    09-14-2014
    Location
    Kuala Lumpur, Malaysia
    MS-Off Ver
    2013
    Posts
    4

    Question To convert cells with break lines into multiple rows and columns

    Hello,

    I have some cells created with line breaks (Alt + Enter) and would like to convert them into multiple rows and columns.

    I got below VBA codes (from pommie98's thread, thanks) but only managed to execute for the first column.

    Please Login or Register  to view this content.
    Could anyone help me on this to extend the action to all the available columns?

    Appreciate your kind sharing and assistance in advance.

    Cheers,
    Leong
    Attached Files Attached Files

  2. #2
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: To convert cells with break lines into multiple rows and columns

    Try this new code:
    Please Login or Register  to view this content.
    多么想要告诉你 我好喜欢你

  3. #3
    Registered User
    Join Date
    09-14-2014
    Location
    Kuala Lumpur, Malaysia
    MS-Off Ver
    2013
    Posts
    4

    Re: To convert cells with break lines into multiple rows and columns

    Thank you so much millz for your kind assistance and the code works very well without error.

    Now i encountered another issue again. Some of my data contain line breaks but some do not (as attached).

    I tried with the new code but got an error, and I believe it was because there isn't any char(10) in the cell.

    Will VBA be able to identify it and continue the code?

    Appreciate your expertise advice and sharing again.

    Cheers,
    Leong
    Attached Files Attached Files

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    12,964

    Re: To convert cells with break lines into multiple rows and columns

    Please Login or Register  to view this content.
    Ben Van Johnson

  5. #5
    Registered User
    Join Date
    09-14-2014
    Location
    Kuala Lumpur, Malaysia
    MS-Off Ver
    2013
    Posts
    4

    Re: To convert cells with break lines into multiple rows and columns

    Hi Johnson,

    Many thanks for your sharing but there seemed to be a Run-time error '1004' when it hits the cell without a line break.

    Please Login or Register  to view this content.
    Could you kindly assist on this?

    Cheers,
    Leong

  6. #6
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    12,964

    Re: To convert cells with break lines into multiple rows and columns

    For each column, for each cell in the column, split the cell value at the line breaks. Copy the elements of the receiver array into a holder array which grows as the cells are split. After the last cell in the column has been processed, write holder array, back to the original column all at once; no cells/rows are inserted.

    Please Login or Register  to view this content.
    Last edited by protonLeah; 09-29-2014 at 09:24 PM.

+ 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. Convert Multiple Columns to Rows including blank cells
    By BJPhil in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-14-2014, 02:48 PM
  2. Replies: 1
    Last Post: 11-29-2012, 06:24 PM
  3. [SOLVED] Break cell into multiple lines by line break
    By Chia in forum Excel General
    Replies: 1
    Last Post: 08-20-2006, 01:40 AM
  4. [SOLVED] Automatically Break Multiple Rows to Two Columns
    By chuangbl in forum Excel General
    Replies: 1
    Last Post: 10-04-2005, 10:05 AM
  5. Sort columns between break lines
    By winstonsnyder in forum Excel General
    Replies: 1
    Last Post: 08-21-2005, 02:05 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