I have a simple macro problem. I have two cells with values that are strings.
I would like to know of a macro that can compare each two cells(start from E2 and compare with E3)to see if the values are NOT equal.
If they are equal, do nothing and if they are NOT, highlight the value.
example:
compare E2&E3, E4,E5,E6,E7,.... if for example E2&E3, E4,E5,E6,E7,.... each has same string, do nothing, but if they were not the same highlight it with red.
this code checks two cells and highlights one cell when there is duplicate, I like the opposit one, but dont know what to change!
Sub CompareCells()
Dim r As Range, cell As Range
Range("E2", Range("E" & Rows.Count).End(xlUp)).Name = ("MyRange")
Range("MyRange").Select
' clear all colors from selection
Selection.Interior.ColorIndex = xlNone
' loop through cells and compare
Set r = Selection
Set r = Selection.Resize(r.Rows.Count + 1)
For Each cell In r
If cell.Offset(1, 0).Value = cell.Value Then
cell.Offset(1, 0).Interior.ColorIndex = 3
End If
Next
End Sub
Thanks for your help.
Bookmarks