Closed Thread
Results 1 to 5 of 5

Split Single Row into Multiple Rows

  1. #1
    Registered User
    Join Date
    10-24-2014
    Location
    DC
    MS-Off Ver
    Mac 14.4.5
    Posts
    6

    Split Single Row into Multiple Rows

    Hello All,

    New User here, and very glad that I found this forum.

    I'm working on a datasheet that contains a large amount of data about people. (It is unfortunately confidential data so Columns A - Column M were deleted).

    Currently, I have one row dedicated per person. Columns A - Column M and Column BB are basic demographic data, and the rest of the Columns are events related to time: ED1, ED1_Time, ED2, ED2_Time, and so forth. I want to convert the data so that it shows multiple rows per person, but that a new ED event and corresponding EDTime has a new row.

    For example:
    TRNUMBEREXAMPLE, MR#, ACCT#, AGE, ...., INJTYPE_AS, ED1, ED1TIME
    TRNUMBEREXAMPLE, MR#, ACCT#, AGE, ...., INJTYPE_AS, ED2, ED2TIME
    TRNUMBEREXAMPLE, MR#, ACCT#, AGE, ...., INJTYPE_AS, ED3, ED3TIME
    TRNUMBEREXAMPLE2, MR#, ACCT#, AGE, ...., INJTYPE_AS, ED1, ED1TIME
    TRNUMBEREXAMPLE2, MR#, ACCT#, AGE, ...., INJTYPE_AS, ED2, ED2TIME

    I found a similar thread that someone was nice enough to post a solution and macrocode for
    http://excelforum.com/excel-general/...iple-rows.html

    However, when I tried to adapt the code, it did not work. I have no experience with macros, and only limited coding experience, and I was unable to modify the code to adapt my code.

    I have attached the spreadsheet that I am working with in .xls and .xlsx formats.

    Thanks for the help in advance. Any help is appreciated!
    Attached Files Attached Files

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Split Single Row into Multiple Rows

    This macro will work with your given data, try this on a small subset of your data. I would recommend you only run this on COPIES of your data.

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Split Single Row into Multiple Rows

    I just noticed there are a lot of times missing in the mass data, so the macro above, which is faster, won't work. We have no choice but to check every cell on every row. Use this instead:

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    10-24-2014
    Location
    DC
    MS-Off Ver
    Mac 14.4.5
    Posts
    6

    Re: Split Single Row into Multiple Rows

    It worked! The original macro code from your first code worked on our full data set.

    Thank you very much!

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Split Single Row into Multiple Rows

    Yes, the original code worked, but due to the missing timestamps sprinkled throughout your data you WERE missing line of data in the results. The second macro dealt with that properly.

    In either case, if that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] VBA Split Cell Contents to New Rows & Copy Cells containing single values to the new rows
    By jaimelwilson in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-14-2017, 05:30 PM
  2. Split single row into multiple rows
    By mbasam in forum Excel General
    Replies: 10
    Last Post: 09-12-2013, 06:09 PM
  3. Replies: 9
    Last Post: 06-06-2013, 11:25 PM
  4. Replies: 10
    Last Post: 07-22-2012, 07:32 PM
  5. 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

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