Option Explicit
Sub CompareDatasets()
' hiker95, 02/25/2014, ME759423
Dim lr1 As Long, lr2 As Long
Dim nrng As Range, c As Range
Application.ScreenUpdating = False
With Sheets("Data Set 1")
lr1 = .Cells(Rows.Count, 1).End(xlUp).Row
With Range("A1:E" & lr1)
.Value = Evaluate("IF(ISTEXT(" & .Address & "),TRIM(" & .Address & "),REPT(" & .Address & ",1))")
End With
With .Range("F2:F" & lr1)
.FormulaR1C1 = "=RC[-5]&RC[-4]"
.Value = .Value
End With
End With
With Sheets("Data Set 2")
lr2 = .Cells(Rows.Count, 1).End(xlUp).Row
With Range("A1:D" & lr2)
.Value = Evaluate("IF(ISTEXT(" & .Address & "),TRIM(" & .Address & "),REPT(" & .Address & ",1))")
End With
With .Range("E2:E" & lr1)
.FormulaR1C1 = "=RC[-4]&RC[-3]"
.Value = .Value
End With
End With
With Sheets("Data Set 1")
For Each c In .Range("F2:F" & lr1)
Set nrng = Sheets("Data Set 2").Range("E2:E" & lr2).Find(c, LookAt:=xlWhole)
If Not nrng Is Nothing Then
If .Cells(c.Row, 4) <> Sheets("Data Set 2").Cells(nrng.Row, 3) Then
.Cells(c.Row, 4).Interior.Color = 65535
Sheets("Data Set 2").Cells(nrng.Row, 3).Interior.Color = 65535
End If
If .Cells(c.Row, 5) <> Sheets("Data Set 2").Cells(nrng.Row, 4) Then
.Cells(c.Row, 5).Interior.Color = 65535
Sheets("Data Set 2").Cells(nrng.Row, 4).Interior.Color = 65535
End If
End If
Next c
End With
With Sheets("Data Set 2")
For Each c In .Range("E2:E" & lr2)
Set nrng = Sheets("Data Set 1").Range("F2:F" & lr1).Find(c, LookAt:=xlWhole)
If Not nrng Is Nothing Then
If .Cells(c.Row, 3) <> Sheets("Data Set 1").Cells(nrng.Row, 4) Then
.Cells(c.Row, 3).Interior.Color = 65535
Sheets("Data Set 1").Cells(nrng.Row, 4).Interior.Color = 65535
End If
If .Cells(c.Row, 4) <> Sheets("Data Set 1").Cells(nrng.Row, 5) Then
.Cells(c.Row, 4).Interior.Color = 65535
Sheets("Data Set 1").Cells(nrng.Row, 5).Interior.Color = 65535
End If
End If
Next c
End With
Sheets("Data Set 1").Range("F2:F" & lr1).ClearContents
Sheets("Data Set 2").Range("E2:E" & lr2).ClearContents
Application.ScreenUpdating = True
End Sub