comparing tables and highlighting the equal cells by vba

comparing tables and highlighting the equal cells by vba
Kindly see the sample file
Sample--1-.xlsm
Avinash SinghAsked:
Who is Participating?
 
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You may try something like this...


Sub CompareTables()
Dim Table1 As Range, Table2 As Range, Table3 As Range
Dim i As Long

Set Table1 = Range("A1:I2")
Set Table2 = Range("A8:I9")
Set Table3 = Range("A13:I14")

Table1.Cells.Interior.ColorIndex = xlNone
Table2.Cells.Interior.ColorIndex = xlNone
Table3.Cells.Interior.ColorIndex = xlNone

For i = 1 To Table1.Cells.Count
    If Table1.Cells(i) <> "" Then
        If Table1.Cells(i) = Table2.Cells(i) Then
            Table1.Cells(i).Interior.ColorIndex = 6
            Table2.Cells(i).Interior.ColorIndex = 6
        End If
        If Table1.Cells(i) = Table3.Cells(i) Then
            Table1.Cells(i).Interior.ColorIndex = 6
            Table3.Cells(i).Interior.ColorIndex = 6
        End If
    End If
Next i
End Sub

Open in new window

0
 
Avinash SinghAuthor Commented:
Thnx for giving ur precious time Subodh Tiwari (Neeraj) Sir
0
 
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You're welcome Avinash!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.