+ Reply to Thread
Results 1 to 12 of 12

Data from multipe rows converted into a single row

  1. #1
    Registered User
    Join Date
    04-23-2013
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2007
    Posts
    7

    Data from multipe rows converted into a single row

    Hello

    I have been scouring help forums trying to find a solution to fit my particular data set. I have installed the MorFunc addin and have tried several macros applications, but to no avail. To put it simply, I have about 2000 rows of data for approximately 900 unique subjects, it


    I have data in the format attached, although some subjects have as many as 5 blood draws (in the example they have a max of 3 blood draws)

    I have.xlsx

    I need it in this format, with all of the blood draws in a single row for each individual subject id.
    I need.xlsx

    I can get examples of various techniques to work, but I have not been able to translate any of it to my data.

    Thank you for your help!
    Clelia
    Attached Images Attached Images

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Data from multipe rows converted into a single row

    Ok


    We can do this using a sort and some formulae,
    We can use a macro to automate that

    Or we can write a dedicated macro which is harder to understand and modify, but could be faster.

    Which do you prefer?

  3. #3
    Registered User
    Join Date
    04-23-2013
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Data from multipe rows converted into a single row

    I am more adept at using formulas than I am with macros, so perhaps that is the best option. Also, I predict that this issue will come up again and again with different types of data so being able to modify it myself is important.

    Thank you for your rapid reply,
    Clelia

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Data from multipe rows converted into a single row

    K

    I have recorded myself doing the sorting an the formulas.

    Now I have to tidy it up.

    BRB

  5. #5
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Data from multipe rows converted into a single row

    Try this Macro.

    It should be easy to understand if you step through it.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    04-23-2013
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Data from multipe rows converted into a single row

    Thank you mehmetcik, I will try this first thing in the morning and let you know how it work!

  7. #7
    Registered User
    Join Date
    04-23-2013
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Data from multipe rows converted into a single row

    I have tried it and it works well on the data that I gave you, however when I run it on my original dataset, it will only give me 2 BloodDrawId2 and AgeMo3... I'm not sure why. I have attached a workbook with two pages- one after I ran the macro and the original set of data. You can see even the SubjectId from my previous example only has 2 BloodDraws and 2 AgeMo-- even though when run on the smaller set it works perfectly. tocolumns-ranMacro.xlsx

    Thank you!

  8. #8
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Data from multipe rows converted into a single row

    My apologies an error crept in there.

    Try running macro1 in the originaldata worksheet.
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,647

    Re: Data from multipe rows converted into a single row

    Here a solution with formulas
    Attached Files Attached Files
    Willem
    English is not my native language sorry for errors
    Please correct me if I'm completely wrong

  10. #10
    Registered User
    Join Date
    04-23-2013
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Data from multipe rows converted into a single row

    This works beautifully! Thank you for your quickness and aptitude!

  11. #11
    Registered User
    Join Date
    04-23-2013
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Data from multipe rows converted into a single row

    Thank you popipipo.. I will check this out, I always like to have more than one approach to a problem.

  12. #12
    Registered User
    Join Date
    04-23-2013
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Data from multipe rows converted into a single row

    Hello

    Can you tell me how I might edit the code to include more columns of data?

+ 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