• Excel Compare Two Columns & Report Differences

    Learn how to compare multiple columns in Excel with huge volume of data.

    1. Find duplicate entry in 2 columns using Conditional Formatting
    2. Compare for duplicates using countif.
    3. Compare Two columns & find duplicates using Excel VBA

    Out of these three methods, the third one is very faster. This methods can be used to compare huge column of data within less time.

    Are you not excited to get such a easy solution?. Read more…

    Also Read: Check If Outlook is Running - then Launch Outlook app - vba code

    Compare & Highlight Matching Duplicate Records

    Assume the data to compare are in Columns A & B. Just to see the duplicate entries with colour difference follow this method.

    1. Select all columns that has data.
    2. Click Home in Excel menu.
    3. Choose “Conditional Formatting” -> “Highlight Cells Rules” -> “Duplicate Values”
    4. Choose the font colour & background to highlight.
    5. Click Ok. Values with repetition will be highlighted.

    No, Excel will compare the data in selected data range and highlight all the duplicate entries.

    The problem with this method, is that it highlights all the differences with same colour. Also we cannot select only the duplicate entries.

    Is that it? No. we have few advanced options too.

    Find Duplicate Entries in Two Columns with Excel Formula

    It can be done with a Lookup or Countif Formula. Countif is simpler compared to a lookup formula.

    How to compare two columns with Countif?

    i.e., Get value from column B, compare it with Column A & find whether any value is repeated.

    1. Assuming Column A & B are to be compared.
    2. Enter this formula in cell C1.
    3. Formula ‘=countif(“$A:$A”,$B1)’
    4. Copy paste this formula in Column C till end of data rows.
    5. Unique values will have count as ‘0’.
    6. Repeating or duplicate entries will have count greater than ‘0’.

    Now we have the comparison data in Column C for B->A verification. The data in Column C can be filtered for unique or duplicate entries.

    If this same process has to be done for A->B comparison, then the formula should be reversed as ‘=countif(“$B:$B,$A1)’

    Also Read: Convert Excel to HTML Table Tags - VBA Macro Code

    Compare & Find duplicate entries in Two columns with Excel VBA Macro

    In Excel VBA, this can be done by plain comparison of each cell with two for loops, which is very efficient for low volume of data.

    In case, if you have huge volume of data, then the above loop will keep on execute for long hours or days to complete. There are also possible chances that Excel application will hang in middle of execution & result in data loss.

    To compare a huge volume of data in your Excel sheet, use this method to find duplicate values and report the differences.

    This code will not take much time. It executes much faster than a normal comparison.

    Much better than this.

    In case if you don’t want to compare all these columns data & in a hurry to remove all duplicate entries. Then Excel has built in option Menu -> Data -> “Remove duplicates’

    Just select all the cells with data and click this option. It will remove all duplicate entries in seconds.

    Duplicates are fine. But how to find unique values?

    Well. It is easy.

    Just use the same VBA code or formula method with countif. Or, you can follow this link to find a technique that uses “Advanced Filter” option within Excel itself.

    Previous Post:
    Next Post: