Im trying to compare cells in 2 tabs (master and test) and if there are changes in test then color changes in any kind of color and copy&paste it to master file.
I used below code to find number of rows in 2 tabs and tried to use IF, but dont know how to finish this code. Could you please help?
Sub compare_files()
Dim c As Range
Dim masterWB, dailyWB As Workbook
Dim mWS, dWS As Worksheet
Dim lRow, lRow2 As Long
Set masterWB = ActiveWorkbook
Set dailyWB = ActiveWorkbook
Set mWS = masterWB.Sheets(1)
Set dWS = dailyWB.Sheets(2)
lRow = mWS.Cells(Rows.Count, "A").End(xlUp).Row
lRow1 = dWS.Cells(Rows.Count, "A").End(xlUp).Row
For Each c In dWS.Range("A2", dWS.Range("A" & Rows.Count).End(xlUp))
If Not dWS.Cells(c.Row, c.Column).Value = mWS.Cells(c.Row, c.Column).Value Then
dWS.Cells(c.Row, c.Column).Interior.Color = vbYellow
End If
Next
End Sub
Aucun commentaire:
Enregistrer un commentaire