Marcos help needed

Closed
Asmodeux
Posts
2
Registration date
Sunday July 28, 2013
Status
Member
Last seen
July 28, 2013
- Jul 28, 2013 at 05:31 AM
Hi,

I need to write a marco that is able to compare the specific column in 2 different worksheets within the same workbook. (i.e Names of staffs)

The differences should be highlighted.

I have tried using the following codes but it didn't work.

Any advise ?

Sub CompareSheets2()

Dim wbk As Workbook
Set wbk = ThisWorkbook

Dim ws2 As Worksheet
Dim ws3 As Worksheet
Set ws2 = wbk.Sheets(2)
Set ws3 = wbk.Sheets(3)

Dim CheckRange As Range
Set CheckRange = ws2.Range("E2:E80")

Dim cell As Range

CheckRange.ClearFormats

For Each cell In CheckRange

If cell.Value <> ws2.Cells(cell.Row, cell.Column).Value Then
cell.Interior.Color = RGB(200, 160, 35)
End If

Next cell

End Sub