Hi All
I have a macro which works fine on one worksheet "Report" which is set as ws. However it is required to run on multiple worksheets with tab names: "Unit", "Training", "Projects". ws1 remains unchanged to "Log". Please could someone tell me what should I do to update the code below:
I have a macro which works fine on one worksheet "Report" which is set as ws. However it is required to run on multiple worksheets with tab names: "Unit", "Training", "Projects". ws1 remains unchanged to "Log". Please could someone tell me what should I do to update the code below:
VBA Code:
Private Sub Reconcile2020()
Dim ws1 As Worksheet, ws As Worksheet, LastRow As Long, LRow As Long, i As Long, r As Long
Set ws = Worksheets("Report")
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 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, "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