I am trying to compare the values from column A of Sheet1 (which I have renamed "AR") and column A of Sheet2 (which I have renamed "Paste Here") and highlight rows containing values that do not exist on the other sheet. (Both columns end with an empty cell.) I found a macro that I thought did something similar to what I wanted here at Efficient removal of duplicate records across multiple Excel sheets, and I am trying to modify it to meet my needs, but I can't make it work.
Currently when I run it, it locks Excel up and I have to do end task on Excel.
This is what I have so far:
Option Explicit
Sub Compare2()
Application.ScreenUpdating = False
Dim startRow As Integer
startRow = 1
Dim row As Integer
row = startRow
Dim bRow As Integer
'sharks below, cap'ain
' This loop is looping on row.
' Scan down column AR!A (i.e., Sheet1!A) until we find an empty cell.
Do While (Worksheets("AR").Range("A" & row).Value <> "")
Dim aVal As String
aVal = Worksheets("AR").Range("A" & row).Value
bRow = startRow 'I see thy booty
' This loop is looping on bRow. Scan down column 'Paste Here'!A
' (i.e., Sheet2!A) until we find an empty cell.
Do While (Worksheets("Paste Here").Range("A" & bRow).Value <> "")
Dim aVal2 As String
aVal2 = Worksheets("Paste Here").Range("A" & bRow).Value
If (aVal <> aVal2) Then
Worksheets("AR").Rows(row).Interior.ColorIndex = 6
' we found a traitor; feed 'em to the sharks
row = row - row
Exit Do
End If
If (aVal2 <> aVal) Then
Worksheets("Paste Here").Rows(row).Interior.ColorIndex = 6
row = row - row
Exit Do
End If
bRow = bRow + 1
Loop
row = row + 1
Loop
End Sub
Any help you can provide would be helpful.