+ Reply to Thread
Results 1 to 9 of 9

Macro to Find Duplicate Values in Two Workbooks

  1. #1
    Registered User
    Join Date
    03-29-2012
    Location
    t
    MS-Off Ver
    Excel 2010
    Posts
    22

    Macro to Find Duplicate Values in Two Workbooks

    Hello,

    I searched through this forum and other sources but could not locate a solution that works for the purposes I am looking for and I am hoping someone hear can point me in the right direction.

    I am looking for a macro that will look up for values (such as tracking IDs) in a column of one spreadsheet (current/working spreadsheet) and compare it against another excel workbook that will house all previously stored historical data (archive). If the value in the current/working spreadsheet already exists in the archived file, it should prompt there user of existence of duplicate entries in the current file and highlight the row(s) with the duplicate value in the current file.

    Thanks for your help.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macro to Find Duplicate Values in Two Workbooks

    Hi beewketu,

    You could load a dictionary from the historical data and then just scan through the new data for a match

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    03-29-2012
    Location
    t
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: Macro to Find Duplicate Values in Two Workbooks

    Hi xladept,

    Thanks for your feedback. I have attached two sample files per your recommendation. The first file (current file) will be the new working document while the file file named Archive will hold historic data. As you can imagine, the historic data will contain large data set and is maintained in a stand alone workbook. The purpose of the macro is to lookup by the tracking ID to make sure there are no duplicate data entries that may have already been completed in the past. These rarely happens but wanted to add a check into the process to ensure quality control. So, the hope is that macro will highlight the duplicate value and advise the user to conduct further research into the matter. And if there are no duplicate to generate a message notifying the user that no duplicate entries have been found.

    I hope that makes sense. Look forward to hear from you.

    Thanks again!
    Attached Files Attached Files

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macro to Find Duplicate Values in Two Workbooks

    Hi beewketu,

    Try this:

    Please Login or Register  to view this content.
    Last edited by xladept; 09-10-2015 at 06:40 PM.

  5. #5
    Registered User
    Join Date
    03-29-2012
    Location
    t
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: Macro to Find Duplicate Values in Two Workbooks

    Thank for writing that code xladept. I am encountering an error message "Run-time error '9': Subscript out of range" when it reaches this part of the code:

    Please Login or Register  to view this content.
    I have both workbooks open at the time of executing the macro with the exact file and tab names so I am not quite sure what the error is.

    Thanks,

  6. #6
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Macro to Find Duplicate Values in Two Workbooks

    Hi beewketu,

    The workbooks being referenced also need to have their extension included, so if the Archive workbook has macros in it, the above line would read as follows:

    Please Login or Register  to view this content.
    Regards,

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  7. #7
    Registered User
    Join Date
    03-29-2012
    Location
    t
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: Macro to Find Duplicate Values in Two Workbooks

    That does it Robert! Thanks to you and xladept for helping me out on this.

    Just out of curiosity, is it feasible to execute the macro without requiring for the file the referenced file (Archive.xlsx) to be opened in the same Excel session?

    Thanks and have a great weekend.

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macro to Find Duplicate Values in Two Workbooks

    Hi beewketu,

    You're welcome!

    Not feasible

  9. #9
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macro to Find Duplicate Values in Two Workbooks

    Hi beewketu,

    Thanks for the rep!

+ 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. [SOLVED] Macro to find duplicate values in different workshhet and change cell colour.
    By Gaztr1x in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-26-2015, 04:12 PM
  2. Macro VBA to comapare two sheets to find duplicate values
    By sumera12 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-18-2014, 06:37 AM
  3. Find and identify duplicate data across multiple workbooks
    By raw_geek in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-23-2013, 02:27 PM
  4. [SOLVED] Macro to find duplicate values in a column and add the corresponding rows
    By hoss88 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-25-2013, 05:40 AM
  5. How to find duplicates from two workbooks (if duplicate add new value in the list)
    By megaexcel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-02-2012, 05:18 PM
  6. Macro to find duplicate values
    By lizzieb in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-06-2010, 04:50 AM
  7. Replies: 2
    Last Post: 09-20-2005, 07:05 AM

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