Hello
I have done a code for you. rest you can do it by yourself.I have used loops, perhaps someone have much easier thing to do. secondly, your tables are not of same diemnsion, the last col of table 2 will always be different. this code only colors table 1 items , for table 2 you can opy code and modify the variables
Option Explicit
Sub remove_duplicate()
Application.ScreenUpdating = False
Dim arr1() As Variant
Dim comarr() As Variant
Dim list1 As Variant
Dim complist As Variant
Dim TheRange As Range
Dim i, j, k, l, m, n, o, p, q, r, s As Long
Dim upper As Long
Dim StartTime As Double
ReDim arr1(17 To 21, 4 To 8)
ReDim comarr(17 To 21, 11 To 16)
For j = 17 To 21
For k = 4 To 8
arr1(j, k) = Cells(j, k).Value
Next
Next
For j = 17 To 21
For k = 11 To 16
comarr(j, k) = Cells(j, k).Value
Next
Next
r = 5
s = 12
For l = 18 To 21
If arr1(l, 4) <> comarr(l, 11) Then
Range(Cells(l, 4), Cells(l, 8)).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Else
For q = 18 To 21
For m = r To 8
For n = s To 15
If arr1(q, m) <> comarr(q, n) Then
Cells(q, m).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
r = r + 1
s = s + 1
Exit For
Else
r = r + 1
s = s + 1
Exit For
End If
Next
Next
Next
End If
Next
End Sub
Bookmarks