+ Reply to Thread
Results 1 to 6 of 6

MACRO to compare two tables and identify changes

  1. #1
    Registered User
    Join Date
    07-18-2012
    Location
    Markham, Ontario
    MS-Off Ver
    Excel 2007
    Posts
    17

    MACRO to compare two tables and identify changes

    I have two data tables side by side in the same worksheet that need to be compared. For this example, each table is 5 columns wide; A-E for first table and G-K for second table. However, the actual tables being used are more like 30 columns wide. I have attached a sample.

    These tables will not be sorted to match each other and may not even have the same amount of rows. The purpose of the macro is to compare the tables and place a comment in column F adjacent the items in columns A.

    The macro I need would do several things
    1. Determine if the item in column A exists in column G. If it does, proceed to compare the data in the other columns. If it doesn't, add a comment "NEW PART" in column F and highlight the entire new row in the first table only. Do this for all rows in the first table.
    2. If the items exist in both tables, the macro would compare all corresponding columns and if any changes are identified, the comment "REVISION" would be placed in column F and the specific changes would be highlighted in yellow.
    3. If the items exist in both tables, and no changes are identified, the comment "NO CHANGE" would be placed in column F.

    The sample file has a before and after of the desired reults. I have experiemented with VLOOKUP but firstly, we would need to sorth the data and also, the formula can become humongous if the table sizes become 30 columns wide.

    Thanks in advance for any help.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    07-18-2012
    Location
    Markham, Ontario
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: MACRO to compare two tables and identify changes

    Any help would be appreciated

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: MACRO to compare two tables and identify changes

    Try the attached
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    07-18-2012
    Location
    Markham, Ontario
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: MACRO to compare two tables and identify changes

    Hi jindon,

    Thank you for the reply. The macro works great. I was not familiar with ubound but we managed to figure it out as the sample file was just a portion of the worksheet that we are using. We have many more columns so we adjusted the macro to suit.

    One problem we found is that with the macro you supplied, if we have less rows of data in the first table than the second table, the macro will highlight the empty rows and state NEW PART when there is nothing there. I have attached a sample using your macro. The empty rows in table 1 should be ignored as I have another way of dealing with this issue. Can you tweak the macro to ignore empty rows in the first table?

    Thanks.
    Attached Files Attached Files

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: MACRO to compare two tables and identify changes

    Add one more If clause...
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    07-18-2012
    Location
    Markham, Ontario
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: MACRO to compare two tables and identify changes

    Works great... thanks

+ 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