I am a beginner.
I should write a program, that compares the all values in all rows in column A, B, C, D, E, with the values in columns G, H, I, J and K in the same row.
If they are all equal, then I need to highlight the row. I wrote the following code, but it does not execute:
Sub compare()
Dim C As Range
Dim D As Range
Dim lastRow As Integer
Dim rng As Range
Dim i As Integer
Dim j As Integer
Dim k As Integer
lastRow = ThisWorkbook.Worksheets("ComparingResult").UsedRange.Rows.Count
'lastColumn = ThisWorkbook.Worksheets("ComparingResult").UsedRange.Columns.Count
Set rng = Range("K:K")
rng.Value = Format(rng.Value, "dd.mm.yyyy")
For i = 2 To lastRow
For j = 1 To 5
For k = 7 To 11
For Each C In ThisWorkbook.Worksheets("ComparingResult").Cells(i, j)
For Each D In ThisWorkbook.Worksheets("ComparingResult").Cells(i, k)
If C = D Then
C.Interior.Color = RGB(102, 255, 255)
D.Interior.Color = RGB(102, 255, 255)
Else
C.Interior.Color = vbWhite
D.Interior.Color = vbWhite
End If
Next k
Next j
Next i
Next
Next
End Sub
Can somebody help me figure out what is wrong with it?