[Solved] Comparing differences in multiple columns [closed]


You can try using below code, it will loop through all lines and compare column A with column G:G if its equal then compare C & H and if is not equal then change the colour index.

Code:

Dim Wb As Workbook, ws As Worksheet, lrow As Long, j As Long, m As Long, lrow2 As Long, Search As Variant, Search2 As Variant
Set Wb = ThisWorkbook
Set ws = Wb.Sheets("Sheet1")
lrow = ws.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Row
lrow2 = ws.Cells(Rows.Count, "G").End(xlUp).Offset(1, 0).Row
    For j = 3 To lrow
        Search = (ws.Cells(j, 1).Value)
        Search2 = (ws.Cells(j, 3).Value)
        For m = 3 To lrow2
        If ws.Cells(m, 7) = Search And ws.Cells(m, 8) <> Search2  Then


            ws.Range("C" & j).Interior.ColorIndex = 3
            ws.Range("H" & m).Interior.ColorIndex = 3

        End If
    Next
    Next

7

solved Comparing differences in multiple columns [closed]