+ Reply to Thread
Results 1 to 3 of 3

Help with copying data between 2 files based on 2 unique matching conditions

  1. #1
    Registered User
    Join Date
    11-05-2010
    Location
    Orlando, FL
    MS-Off Ver
    Excel 2010
    Posts
    47

    Help with copying data between 2 files based on 2 unique matching conditions

    So I'm finishing up a study right now and am hoping to get some help with a macro which will help to reorganize all the data.

    So the software we're using will automatically generate data files based off of each participants data. Theres 4 different conditions in the study and the program will organize each persons data based on the particular condition they were in. So I'll have say a "Full-Auto Progress Data" file which will have each participants number in column A and then the related data in each additional column for every participants run through the full-auto condition. Columns C-L have all the data I need.

    Now in the master data file we're creating column A represents the participant, and column B the specific condition they were in (Full auto, semi, manual, semi-vis). After that columns D-M contain all the data being pulled from the individual conditions files.

    The master data file looks like this for an example

    1020 semi
    1020 semi-vis
    1020 auto
    1020 manual
    1021 manual
    etc....

    Is there some type of VB module I could use to open up one of the condition files, like the "Full-Auto Progress Data" and then copy the data for each participant over into the master file by matching the participants number and using the condition in column B "Full-Auto" in this case as a qualifier for the copy?

    For each of the 4 condition files it would need to match up the participant number, and then insert the data only if next to the participant number it has the correct condition. I have attached the files for reference, but the encap master attachment is just the one sheet from the master document. If it makes things trickery to insert it into a specific sheet of a file I can always have a file just for the encapsulation and copy that whole sheet over at the end. Right now I've been manually going through and copying a rows from each file over into the master, and it's quite time consuming with as much data as we're beginning to generate. If anyone can help it'd be appreciated.

    Note* The generated files for each condition are in an .csv format but I do have a converter if they need to all be in .xls or .xlsx
    Attached Files Attached Files

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Help with copying data between 2 files based on 2 unique matching conditions

    Try the code below

    Please Login or Register  to view this content.

    You will need to have both workbooks open and use the switch windows button to select the source sheet.

    Open up the VBA editor by hitting ALT F11

    Insert a new module by hitting Insert - Module

    Paste the macro into the empty sheet

    Hit ALT F11 to get back to the worksheet.

    Run the macro by going to tools-macro in Excel 2003 or the view ribbon in Excel 2007.
    Martin

  3. #3
    Registered User
    Join Date
    11-05-2010
    Location
    Orlando, FL
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Help with copying data between 2 files based on 2 unique matching conditions

    Wow, tried it again and it did work, i didn't have them in the same book >.< Anyway thanks for the help this macro is a awesome.
    Last edited by cowboy713; 11-22-2010 at 05:46 PM. Reason: SOLVED

+ 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