John,
Here is a "general" routine which compares two columns (lists)
of data - MASTER in column A and UPDATE in column B. Data starts in row 2.
It lists Matches, Master Only and Update only. You can adapt for your own
needs.
HTH
Sub CompareTwoColumns()
Dim rngA As Range
Dim rngB As Range
Dim rw1 As Long
Dim rw2 As Long
Dim rw3 As Long
Dim Start as Double, Finish as Double, TotalTime as Double
Start = Timer ' Set start time.
headings = Array("Master", "Update", "Matched", "Master Only", "Update Only")
Application.ScreenUpdating = False
Set ws1 = Worksheets("Sheet1")
Set ws2 = Worksheets("Sheet1")
With ws1
Set rngA = .Range(Cells(2, 1), Cells(Rows.Count, 1).End(xlUp))
End With
With ws2
Set rngB = .Range(Cells(2, 2), Cells(Rows.Count, 2).End(xlUp))
End With
rw1 = 2
rw2 = 2
rw3 = 2
ws1.Columns("C:E").ClearContents
ws1.Range("a1").Resize(1, 5) = headings
' In column A and column B
For Each Cell In rngA
If Not IsError(Application.Match(Cell.Value, rngB, 0)) Then
ws1.Cells(rw1, 3).Value = Cell.Value
rw1 = rw1 + 1
End If
Next
' In column A but not in column B
For Each Cell In rngA
If IsError(Application.Match(Cell.Value, rngB, 0)) Then
ws1.Cells(rw2, 4).Value = Cell.Value
rw2 = rw2 + 1
End If
Next
' In column B but not in column A
For Each Cell In rngB
If IsError(Application.Match(Cell.Value, rngA, 0)) Then
ws1.Cells(rw3, 5).Value = Cell.Value
rw3 = rw3 + 1
End If
Next
Application.ScreenUpdating = True
Finish = Timer ' Set end time.
TotalTime = Finish - Start ' Calculate total time.
MsgBox "Ran for " & TotalTime & " seconds"
End Sub