+ Reply to Thread
Results 1 to 3 of 3

Macro for comparing two worksheets and copying new data based on 2 column unique key?

  1. #1
    Registered User
    Join Date
    03-07-2012
    Location
    vancouver, bc
    MS-Off Ver
    Excel 2007
    Posts
    2

    Macro for comparing two worksheets and copying new data based on 2 column unique key?

    Hello,

    I am trying to write a Macro for the following problem:

    I have two workbooks. Workbook A has multiple sheets, one of which is a list of projects with several columns including: project number, project year, and project title. The second workbook, Workbook B, has only one worksheet that looks up values from that project list sheet in Workbook A. What I need is a macro that finds new projects that have been added to Workbook A and imports project number, project year and project title for those new projects into Workbook B. New projects are identified by comparing the project list from Workbook A to the sheet in Workbook B based on a unique key of Project Number + Project Year.

    Thank you in advance for any help!!

  2. #2
    Valued Forum Contributor
    Join Date
    06-17-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2003,excel 2007
    Posts
    678

    Re: Macro for comparing two worksheets and copying new data based on 2 column unique key?

    how is the project is entered under project in both the sheets

    from your text I presume
    in workbook A project name and year entered in two different columns
    e.g.

    project year
    a 2005
    s 2006
    d 2007
    s 2008
    a 2009


    in workbooks B it is entered in the only column as
    a<space>2005
    a<space>2009

    is this the configuration?????????????
    better send a sample sheets in both workbooks.
    I am not an expert. better solutions may be available
    $$$$venkat1926$$$$@gmail.com

  3. #3
    Registered User
    Join Date
    03-07-2012
    Location
    vancouver, bc
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Macro for comparing two worksheets and copying new data based on 2 column unique key?

    Hello,

    Thanks for your reply.
    To answer your question, in both workbooks Project Number and Project Year are in different columns.
    I've attached two example workbooks. The actual data contains more columns than what I have provided, but the relevant columns are included.

    Basically what I need is a Macro that does this:

    For each row in WorkbookA.ProjectList:
    Look for a row in WorkbookB.Sheet1 that has the same Project Number and Project Name.
    If there is no match
    then copy the project number, project year and project title over from that row in WorkbookA.ProjectList and insert them into WorkbookB.Sheet1.

    Thanks again!
    Attached Files Attached Files
    Last edited by blh5; 03-09-2012 at 02:02 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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