Hi All
My macro was working fine until I added in the elseif for "ABC". The error message is "Compile error: Else without if". Please could anyone tell me what have I done wrong, thanks.
My macro was working fine until I added in the elseif for "ABC". The error message is "Compile error: Else without if". Please could anyone tell me what have I done wrong, thanks.
VBA Code:
Dim ws1 As Worksheet, ws As Worksheet, LastRow As Long, LRow As Long, i As Long, r As Long
Set ws = Worksheets("Tracker")
Set ws1 = Worksheets("Log")
LastRow = ws.Cells(Rows.Count, "A").End(xlUp).Row
LRow = ws1.Cells(Rows.Count, "A").End(xlUp).Row
For i = LRow To 2 Step -1
For r = LastRow To 2 Step -1
If ws.Cells(r, "A").Value = "ABC" _
And ws1.Cells(i, "A").Value = ws.Cells(r, "A").Value _
And ws1.Cells(i, "B").Value = ws.Cells(r, "B").Value _
And ws1.Cells(i, "C").Value = ws.Cells(r, "C").Value _
And ws1.Cells(i, "E").Value = ws.Cells(r, "E").Value _
And ws1.Cells(i, "F").Value = ws.Cells(r, "F").Value Then
For Each Z In Array("D", "G", "H", "I", "J")
ElseIf ws.Cells(r, "A").Value <> "ABC" _
And ws1.Cells(i, "A").Value = ws.Cells(r, "A").Value _
And ws1.Cells(i, "B").Value = ws.Cells(r, "B").Value _
And ws1.Cells(i, "E").Value = ws.Cells(r, "E").Value _
And ws1.Cells(i, "F").Value = ws.Cells(r, "F").Value Then
For Each Z In Array("C", "D", "G", "H", "I", "J")
If ws1.Cells(i, Z).Value <> ws.Cells(r, Z).Value Then
ws1.Cells(i, Z).Interior.ColorIndex = 6
ws.Cells(r, Z).Value = ws1.Cells(i, Z).Value
End If
Next Z
End If
Next r
Next i
End Sub