Greetings,
I have a macro (which runs painfully slow) that highlights unique cells between two ranges on different worksheets. I've been trying to add a message box that displays the number of unique cells but the method below has not been working:
I have a macro (which runs painfully slow) that highlights unique cells between two ranges on different worksheets. I've been trying to add a message box that displays the number of unique cells but the method below has not been working:
Code:
Sub HighlightDuplicates()
Application.DisplayAlerts = False
lrU = Sheets("Util").Cells(Rows.Count, 1).End(xlUp).Row
lrPT = Sheets("PivtTable").Cells(Rows.Count, 1).End(xlUp).Row
Dim rng1, rng2, cell1, cell2 As Range
Dim mydiffs As Integer
Set rng1 = Worksheets("Sheet1").Range("DL4:DL" & lrU)
Set rng2 = Worksheets("Sheet2").Range("E3:M" & lrPT)
For Each cell1 In rng1
For Each cell2 In rng2
If Not cell1.Value = cell2.Value Then
cell2.Interior.Color = vbRed
mydiffs = mydiffs + 1
End If
Next cell2
Next cell1
'Display a message box to demonstrate the differences
MsgBox mydiffs & " differences found", vbInformation
Application.DisplayAlerts = True
End Sub