+ Reply to Thread
Results 1 to 21 of 21

Combine info from two excel sheet

  1. #1
    Registered User
    Join Date
    03-26-2017
    Location
    London
    MS-Off Ver
    13
    Posts
    23

    Combine info from two excel sheet

    Hi,

    I have two separate excel sheets and I would like to combine information from both of them.

    In sheet 1 I have participant ID, medications using (can be multiple per individual), medication dose, medication start and stop time.

    In sheet 2 I have participant ID and visit dates whereby participants had an assessment.

    For each participant I would like to record which medication they were on (and at what dose) during each assessment. The assessment date differs slightly between each individual.

    Visit dates and start/stop times of medication are written in days. All participants had their first assessment on day 0. Therefore medication dates can be before that (i.e. -30).

    It gets complicated because someone may have been on a drug at a certain dose for their first visit and then the same drug at another dose on subsequent visits.

    Please let me know whether I can provide anymore info!

    Thanks!
    Attached Files Attached Files

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,876

    Re: Combine info from two excel sheet

    If you unpivot your data in Sheet 2 then you can align your data. Reformat your sheet 2 so that your data is in the following format

    Subject in Column A
    Assessment #
    Value of Assessment.

    Then you can use Vlookup or index/Match or Power Query or VBA to easily do your analysis
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    03-26-2017
    Location
    London
    MS-Off Ver
    13
    Posts
    23

    Re: Combine info from two excel sheet

    Hi Alan,

    Thanks for your help. I have changed the format like you suggested (attached). Please may you give me more guidance regarding the next steps? (Vlookup or index/Match or Power Query or VBA). I am basically a complete beginner at excel.

    Thanks,

    Kate
    Attached Files Attached Files

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,876

    Re: Combine info from two excel sheet

    How do you know which assessment relates to which drug? I can see the relationship between participants but cannot see the same for the drug.

  5. #5
    Registered User
    Join Date
    03-26-2017
    Location
    London
    MS-Off Ver
    13
    Posts
    23

    Re: Combine info from two excel sheet

    Hi Alan,

    The assessment day and the medication start/ stop date need to be compared.

    So for participant 1, they had their first assessment on day 0, their second assessment on day 371, third on day 734 and fourth on 1098. Looking at
    sheet 1, they were on 37.5mg drug 1 from day 0- 283. Therefore, they were on this drug/dose during their first assessment (day 0). For the rest of
    their visits they were on 100mg drug 1. They were also on 2.5mg of drug 2 for the final assessment.

    I am unable to do this manually as I have thousands of participants. Is there a way to do this in excel?

    Thanks,

    Kate

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,876

    Re: Combine info from two excel sheet

    Kate,
    I cannot visualize a solution for your, but I am going to raise the issue with other more skilled members of our forum.

  7. #7
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,552

    Re: Combine info from two excel sheet

    I am offering this as a starter proposal and believe (hope) that some of the other contributors will give better answers.
    Using the set up in the file attached to post #1 I produced a table populated using:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Note that the table shows results for the subjid listed in the drop down in cell B2.
    Let us know if you have any questions.
    Attached Files Attached Files
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  8. #8
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Combine info from two excel sheet

    An alternative, using your sample file from post #3 and, further assuming, you want the results on Sheet2 (i.e. adjacent to the Assessments)
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    the above will give you a colon delimited drug + associated dosage value, per med, which were active during given assessment
    you can expand further (to right) if possible that you have more than 3 meds to account for on a given visit.

    note: you will get some odd results for partcipant 1 given you have them changing dose on same day - i.e. end date & start date are the same, in reality either/or date should be adjusted to reflect whichever dose was active on that date / during visit.
    Attached Files Attached Files
    Last edited by XLent; 01-30-2019 at 06:00 AM. Reason: added attachment to illustrate

  9. #9
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Combine info from two excel sheet

    apologies I just realised you're on 2013 rather than 2016 so the use of TEXTJOIN isn't feasible; you can remove this and repeat the INDEX call for B & C - just less efficient (and verbose!)

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    03-26-2017
    Location
    London
    MS-Off Ver
    13
    Posts
    23

    Re: Combine info from two excel sheet

    Hi JeteMc,

    Thanks for taking the time to work on this. The layout of this solution works well but I was wondering whether I can get all the values to show up all at once rather than only seeing the answers when I select each participant via B2? Especially because the B2 cell only allows me to choose the first 6 participants.

    Thanks!

  11. #11
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Combine info from two excel sheet

    @London123, I've reattached my earlier suggestion but with the 2013 compatible function outlined in prior post -- perhaps that will help?
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    03-26-2017
    Location
    London
    MS-Off Ver
    13
    Posts
    23

    Re: Combine info from two excel sheet

    Hi XLent,

    Thanks so much for your help so far. I am sure its just something I have done, but when I copy this formula the cells are blank. I am obviously working with a larger spreadsheet than in the example (but all columns are the same) and so I have updated the number of rows (i.e. changing (Sheet1!$B$2:$B$29) to (Sheet1!$B$2:$B$3414). Is there anything else I need to update?

    I'm also not sure if its relevant that the IDs are not 1,2,3 etc but are longer numbers which begin with a letter. Everything else is the same.

    Thanks!
    Last edited by London123; 01-30-2019 at 03:56 PM.

  13. #13
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,552

    Re: Combine info from two excel sheet

    That the ID's begin with a letter is important. Try this modification of XLent's formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Let us know if you have any questions.

  14. #14
    Registered User
    Join Date
    03-26-2017
    Location
    London
    MS-Off Ver
    13
    Posts
    23

    Re: Combine info from two excel sheet

    Thanks JeteMC!

    Now it gives the correct answer for the first participant but it just repeats this answer for each subsequent participant. Does it need updating again?

  15. #15
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Combine info from two excel sheet

    If you can, post an update sample which reflects your real life (devoid of sensitive info) and we can review.

  16. #16
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Combine info from two excel sheet

    Quote Originally Posted by London123 View Post
    I am obviously working with a larger spreadsheet than in the example (but all columns are the same) and so I have updated the number of rows (i.e. changing (Sheet1!$B$2:$B$29) to (Sheet1!$B$2:$B$3414)
    just reading back the above, did you replace all references to $29 with $3414?

    taking the formula JeteMc provided, which caters for the ID# being various data types, you would get:

    Formula: copy to clipboard
    Please Login or Register  to view this content.

    if the above doesn't work, could you please try

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    where "x" represents a seemingly "blank" row, and advise the answer.

  17. #17
    Registered User
    Join Date
    03-26-2017
    Location
    London
    MS-Off Ver
    13
    Posts
    23

    Re: Combine info from two excel sheet

    It's attached but now the cells are blank again. When I changed the drug names its was still 'working' as before (it worked for the first participant but then just repeated the answers for the other participants). However, when I changed the participant IDs it went blank again. I have tried using a letter and a number (the real IDs are 10 digits starting with a letter followed by 9 numbers. The first 5 digits of each ID are the same for all participants).

    Thanks so much for all your help.
    Attached Files Attached Files

  18. #18
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Combine info from two excel sheet

    see the attached; your prior sample is linking to another workbook so I've updated this, the row references, and fixed a typo in the LOOKUP function.
    Attached Files Attached Files

  19. #19
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,552

    Re: Combine info from two excel sheet

    My mistake, try the following:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Let us know if you have any questions/problems.
    Attached Files Attached Files

  20. #20
    Registered User
    Join Date
    03-26-2017
    Location
    London
    MS-Off Ver
    13
    Posts
    23

    Re: Combine info from two excel sheet

    Hi JeteMc,

    Sorry for being such a pain. Regarding your last message at 1.58 its working now but only to row 24 (which is the size of my example file). Is there something in the formula which stops at this point?

    Thanks,

  21. #21
    Registered User
    Join Date
    03-26-2017
    Location
    London
    MS-Off Ver
    13
    Posts
    23

    Re: Combine info from two excel sheet

    Hi XLent,

    In reply to your message sent today at 11.48 I have used the first formula and it is working well!

    Thank you so much for all your help, you have save me many hours/ days of doing this manually.

+ 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. Button takes info from Sheet 1, transcribes to Sheet 2, info deletes on Sheet 1
    By LNT225 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-02-2016, 04:54 PM
  2. Replies: 3
    Last Post: 04-12-2015, 04:01 PM
  3. Replies: 1
    Last Post: 04-11-2015, 02:16 AM
  4. Replies: 1
    Last Post: 03-11-2013, 05:37 AM
  5. Excel 2007 inserting info from sheet to sheet
    By magica in forum Excel General
    Replies: 0
    Last Post: 12-14-2010, 06:11 AM
  6. Replies: 3
    Last Post: 04-15-2010, 08:36 PM
  7. [SOLVED] info in Excel import into Access to combine multiple records then.
    By farm dog dad in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-30-2005, 11: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