Find value difference in two worksheets

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,699
Office Version
  1. 2007
Platform
  1. Windows
Morning,
I have two sets of letters / number codes & wish to be informed of the difference between the two.

Example.
The first set are on worksheet called OLD & in range A1:J30

The second are in worksheet called NEW & are also in range A1:J30

I would like on worksheet NEW for the different values to be highlighted.

Example of what should happen.
The excel code would compare values in worksheet OLD A1 with worksheet NEW A1 if the value is the same then continue to the next value BUT If the value is different then on worksheet NEW highlight cell A1 yellow then continue doing the same for the rest in the range.

Many thanks.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
In my head I have something like what I think it should do but never able to put it on paper.
Example.

If A1 OLD <> A1 NEW Then A1 NEW vbYellow.
 
Upvote 0
Try:
VBA Code:
Sub CompareData()
    Application.ScreenUpdating = False
    Dim ws1 As Worksheet, ws2 As Worksheet, a As Variant, i As Long, ii As Long
    Set ws1 = Sheets("OLD")
    Set ws2 = Sheets("NEW")
    With ws1.[a1].CurrentRegion
        a = .Value
        For i = LBound(a) To UBound(a) 'loops throught rows
            For ii = LBound(a, 2) To UBound(a, 2) 'loops through columns
                If a(i, ii) <> ws2.Cells(i, ii) Then
                    ws2.Cells(i, ii).Interior.ColorIndex = 3
                End If
            Next ii
        Next i
    End With
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,275
Messages
6,171,126
Members
452,381
Latest member
Nova88

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