Compare 2 table with varying data to show differences

kvmike

New Member
Joined
Feb 28, 2022
Messages
11
Office Version
  1. 365
Platform
  1. Windows
Hi,

I pull a report weekly for my role which contains multiple columns of data, each row has its own unique ID.
Each week when i pull the report, currently i am manually comparing the 2 tables to see if there are any differences and copying any changes from the new report into the old table. Also adding any new entries that come through in the new report into the old table.
I was wondering if there is a faster way of doing this?
My main objectives are to highlight any differences between the old report and the new report for each unique ID.
Here is an example table below to give you an idea:

Old Report:
IDNameStatusTotal Contract ValueEstimated Contract Received Date
779513Ethernet bulkQuoting£ 600
30/06/2019​
1046170MPLS replacementSigned Contract£ 110,000
25/08/2021​
1069535AP bulkQuoting£ 14,647
28/09/2021​

New Report:
IDNameStatusTotal Contract ValueEstimated Contract Received Date
779513Ethernet bulkSigned Contract£ 1000
30/06/2019​
1046170MPLS replacementSigned Contract£ 110,000
25/08/2021​
1069535AP bulk (went with another provider)Lost£ 14,647
28/09/2021​

Any help is greatly appreciated!
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Questions that helpers out there might want to ask:
1) Are New Report and Old Report in the same workbook?
2) How would you like the resulting Old Report to be like since you mentioned highlight difference and also copy any changes.?
 
Upvote 0
Yes, the new and old are in the same workbook.
My goal is for:
  • The old report to cross check each unique ID, and its corresponding cells against the same ID in the new report.
  • If the ID's corresponding cells in the old report differ to those in the new report, then I want it to highlight those cells so it brings them to my attention. I can then manually investigate what's changed since I last ran my report.
  • If there is no difference found when checking the above, i want it to do nothing and leave the data in the cell being crosschecked alone.
Unsure if this is at all possible, or if there is a much simpler method to doing this? thank you
 
Upvote 0
Sorry for late reply. I was hoping that someone respond before me ?

I created a macro to take each ID in old report and compare to new report. If matching ID is found, then each data in column is compared and highlight cell in old report if corresponding cell is different. The macro is self explanatory.
VBA Code:
Sub Compare()

Dim nCol As Long
Dim IDOld As Range, IDNew As Range
Dim rngIDOld As Range, rngIDNew As Range, rngFound As Range
Dim wsOld As Worksheet, wsNew As Worksheet

' Assign names for Report Old and Report New
Set wsOld = ActiveWorkbook.Sheets("Report Old")
Set wsNew = ActiveWorkbook.Sheets("Report New")

' Declare ID ranges for Report Old and Report New
Set rngIDOld = wsOld.Range("A2", wsOld.Cells(Rows.Count, "A").End(xlUp))
Set rngIDNew = wsNew.Range("A2", wsNew.Cells(Rows.Count, "A").End(xlUp))

' Clear any previous highlight. Assuming your data range is from A2 to E & end of data row
wsOld.Range("A2", wsOld.Cells(Rows.Count, "E").End(xlUp)).Interior.Color = xlNone

For Each IDOld In rngIDOld
    Set rngFound = rngIDNew.Find(IDOld)
    If Not rngFound Is Nothing Then
        For nCol = 2 To 5
            If Not wsNew.Cells(rngFound.Row, nCol) = wsOld.Cells(IDOld.Row, nCol) Then
                wsOld.Cells(IDOld.Row, nCol).Interior.Color = vbYellow
            End If
        Next
    End If
Next

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top