+ Reply to Thread
Results 1 to 11 of 11

Split single row into multiple rows

  1. #1
    Registered User
    Join Date
    07-13-2013
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    3

    Split single row into multiple rows

    Hey everyone, I'm a new user here and glad I found this forum. Thanks in advance for your time and help.

    I'm working on a worksheet that contains a large amount of data about people. Currently, I have one row dedicated per person with their demographics and survey data in separate columns. The data is such that a few columns are dedicated to demographics (name, age, etc.) and the remaining columns contain information organized by time (favoritecolor1,time1,date1, favoritecolor2,time2,date2, favoritecolor3,time3,date3, etc.). I want to convert the data so it shows multiple rows per person, but they're separated by time. row 1 would be: "john doe, 31, favoritecolor1,time1,date1", row 2 would be "john doe, 31, favoritecolor2,time2,date2", row 3 would be "john doe, 31, favoritecolor3,time3,date3", and so on and so forth. I would do it manually but the issue is that I have about 90 columns of survey data per person, split into 30 or so different time points.

    In case it's still not clear, let me explain in terms of numbers. Now, for example, I have 5 rows and 10 columns. Columns 1-4 are static (information doesn't change) while columns 5 -10 are repeated trials taken at different time points (every 2 columns=1 time point of data) so 3 different time points with three pieces of information taken at each time. I want to have 15 rows and 6 columns (3 rows per person representing the different time points of data, columns 1-4 static and columns 5-6 variable).

    Any help is appreciated. I don't have any experience with VB or macros so if the answer lies therein, please explain steps required or point me in that direction with any links you may have. If my explanation is bad, please let me know and I'll post tables. Thanks!!!

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Split single row into multiple rows

    Hi and welcome to the forum

    i would suggest you upload a sample work book, (all sensitive data removed), showing what data you are working with, a few examples of what your expected outcome is, and how you arrived at that
    To attach a file to your post,
    click advanced (next to quick post),
    scroll down until you see "manage file",
    click that and select "add files" (top right corner).
    click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Valued Forum Contributor
    Join Date
    09-25-2011
    Location
    Eastbourne, England
    MS-Off Ver
    Excel 2010
    Posts
    1,089

    Re: Split single row into multiple rows

    Hi mbasam

    In your example highlight A1:D5. Hold down Ctrl and highlight G1:H5. Copy. Go to A6 and paste.
    Highlight A1:D5. Hold down Ctrl and highlight i1:j5. Copy. Go to A11 and paste.
    Sort by A

    If this does not work, I suggest you follw the excellent advice of FDibbins and upload a sample.

    Regards
    Alastair

  4. #4
    Registered User
    Join Date
    07-13-2013
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Split single row into multiple rows

    sample.xlsx
    Quote Originally Posted by FDibbins View Post
    Hi and welcome to the forum

    i would suggest you upload a sample work book, (all sensitive data removed), showing what data you are working with, a few examples of what your expected outcome is, and how you arrived at that
    To attach a file to your post,
    click advanced (next to quick post),
    scroll down until you see "manage file",
    click that and select "add files" (top right corner).
    click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.
    Thanks, FDibbins. I'm attaching a sample file with "before" for what I have and "After" of what I would like to have. Thanks for your help!

    Mbasam

    Quote Originally Posted by aydeegee View Post
    Hi mbasam

    In your example highlight A1:D5. Hold down Ctrl and highlight G1:H5. Copy. Go to A6 and paste.
    Highlight A1:D5. Hold down Ctrl and highlight i1:j5. Copy. Go to A11 and paste.
    Sort by A

    If this does not work, I suggest you follw the excellent advice of FDibbins and upload a sample.

    Regards
    Alastair
    I would do this, except it wouldn't work for my data set (please see examples). Thanks for the help!

  5. #5
    Valued Forum Contributor
    Join Date
    09-25-2011
    Location
    Eastbourne, England
    MS-Off Ver
    Excel 2010
    Posts
    1,089

    Re: Split single row into multiple rows

    Hi mbasam

    Sorry it does not work for you - it works for me on your data.
    Any VBA solution that I would write would be based on that solution.

    Regards
    Alastair

  6. #6
    Registered User
    Join Date
    07-13-2013
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Split single row into multiple rows

    Quote Originally Posted by aydeegee View Post
    Hi mbasam

    Sorry it does not work for you - it works for me on your data.
    Any VBA solution that I would write would be based on that solution.

    Regards
    Alastair
    Alastair,
    Thanks so much for your help, it worked! Before, it wasn't allowing me to CTRL+copy multiple selections for some reason. I tried again and it worked. Is there a way to do this with VBA coding that is less time consuming? I am starting with 300 rows and 200 columns. If not, this is fine.

    Thanks again for all your help!

    Mbasam

  7. #7
    Valued Forum Contributor
    Join Date
    09-25-2011
    Location
    Eastbourne, England
    MS-Off Ver
    Excel 2010
    Posts
    1,089

    Re: Split single row into multiple rows

    Hi mbasam

    I think that he attached should work for you.

    Press Ctrl+shift+Q to run the macro

    Use Alt+F8 / "Step into" to see the code.

    Let me know how you get on

    Regards
    Alastair
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    09-12-2013
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Split single row into multiple rows

    Hi Alastair ,

    I have a very similar problem, only instead of 3 timepoints with 3 columns of data each, I have 25 timepoints with 66 columns of data each. I don't know enough vba to tell me how do edit the macro. Could you tell me what needs to be changed? Thanks in advance.

    Meira Bracha

  9. #9
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Split single row into multiple rows

    mbracha welcome to the forum

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.

  10. #10
    Registered User
    Join Date
    09-12-2013
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Split single row into multiple rows

    Sorry - I'm new here. I should have read the rules more carefully. Please accept my apology.

    Meira Bracha.

  11. #11
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Split single row into multiple rows

    No problem, thanks for the understanding

+ 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. Replies: 9
    Last Post: 06-06-2013, 11:25 PM
  2. Replies: 5
    Last Post: 05-25-2013, 07:12 AM
  3. Replies: 10
    Last Post: 07-22-2012, 07:32 PM
  4. Macro to split a single cell data into rows and copying other cells as it is in rows
    By Pankaj Sonawane in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 08-25-2010, 07:09 PM
  5. Replies: 2
    Last Post: 09-24-2006, 08:33 AM

Tags for this Thread

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