Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #30252
    David
    Participant

    I frequently face the following requirement, and would appreciate some advice from you all.

    These files may have tens or even hundreds of lines (we can think of it as a single column of data).
    Let’s assume a file has one column and consists of 9 lines. I need to split this into 3 columns, so lines 1-3 remain in Column A, lines 4-6 are moved to Column B, and lines 7-9 are moved to Column C. The columns should be separated by commas.

    Original File:
    1
    2
    3
    4
    5
    6
    7
    8
    9

    Desired Output:
    Column A,Column B,Column C
    1,4,7
    2,5,8
    3,6,9

    If the file has 10 lines, then, compared to the previous example, it would have a Column D only contains the last number 10.

    Desired Output:
    Column A,Column B,Column C,Column D
    1,4,7,10
    2,5,8
    3,6,9

    The above is just a simple example. In fact, the number of lines to split each time may vary — the example used 3, but it could also be 10 or another number.
    Do you have any idea how to handle it quickly? Now I handle them manually.

    #30253
    Patrick C
    Participant
    #30256
    David
    Participant

    Hello Patrick, this macro is amazing; it perfectly solved my problem. I sincerely appreciate your help. Thank you!

    #30257
    Patrick C
    Participant

    Glad I could help.
    Thanks for your feedback!

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.