+ Reply to Thread
Results 1 to 4 of 4

Compare 2 cells on sheet1 with 2 cells on sheet2 and copy unmatched rows to sheet3

  1. #1
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Compare 2 cells on sheet1 with 2 cells on sheet2 and copy unmatched rows to sheet3

    Hello all. I have searched the forum and found the following code that I think will do what I need, but the changes I made do not produce any results:

    Please Login or Register  to view this content.
    Basically I sheet1 has columns A and B (item number and date that together identify the item) that need to be compared to each row on sheet2 columns A and B. If sheet1 does not match sheet2 then copy the row from sheet1 to sheet3. The columns are not matched from sheet1 to sheet2 independantly, but as a pair.

    For example:

    sheet1 sheet2
    colA colB colA colB

    z12 1/1/2001 as6 5/6/2007
    z12 1/1/2004 f6 5/6/1999
    152 1/3/2001 gh9 5/20/2007
    z12 2/1/2001 z12 1/1/2001
    999 7/1/2001 z18 1/1/2001

    Since only the z12 1/1/2001 is common to both sheets, all the other rows should be copied to sheet3.

    The code above runs and ends but there is no data on sheet3 or error.


    Thanks in advance for your assistance,
    Andrew
    Last edited by drewship; 10-14-2010 at 07:20 AM.

  2. #2
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: Compare 2 cells on sheet1 with 2 cells on sheet2 and copy unmatched rows to sheet

    I have amended the code a bit and it now copies EVERYTHING from sheet1 to sheet3. I need to copy only the rows from the UNMATCHED column A and B combinations. Still working on it. See attached file.
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: Compare 2 cells on sheet1 with 2 cells on sheet2 and copy unmatched rows to sheet

    Found another bit of code that I modified and seems to be working except that it copies some rows to sheet3 twice and others once. I uploaded the new workbook which displays this duplication when the macro is run. I used named ranges in the hopes that they would keep columns A and B tied to each other on their respective sheets. Any thought as to why some rows are being duplicated on sheet3?

    Thanks,
    Andrew

    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: Compare 2 cells on sheet1 with 2 cells on sheet2 and copy unmatched rows to sheet

    I think I have worked out a solution to duplicates being copied to sheet3, but would rather have the code not copy duplicates in the first place if someone can help fix it. Thanks!!

    Please Login or Register  to view this content.
    Attached Files Attached Files

+ 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