Hello. I am looking forward to getting a code that enables me to compare the first and second columns of all the sheets of the workbook with the first and second columns of the main sheet. When the same value is checked, the values of column C, D, and E are copied to the same row. The purpose of the code is to modify the data from the main and copy it back to its place on the sheets. Thank you in advance
VBA Code:
Sub test()
Set sht = sheet1
Set sht2 = sheet2
SrcLastRow = sht.Cells(sht.Rows.Count, 1).End(xlUp).Row
DestLastRow = sht2.Cells(sht2.Rows.Count, 1).End(xlUp).Row
For I = 2 To SrcLastRow
For k = 2 To DestLastRow
If sht2.Cells(k, 1).Value = sht.Cells(I, 1).Value And _
sht2.Cells(k, 2).Value = sht.Cells(I, 2).Value Then _
sht2.Cells(k, 2).Value = sht.Cells(I, 2).Value
sht2.Cells(k, 3).Value = sht.Cells(I, 3).Value
sht2.Cells(k, 4).Value = sht.Cells(I, 4).Value
sht2.Cells(k, 4).Value = sht.Cells(I, 4).Value
sht2.Cells(k, 5).Value = sht.Cells(I, 5).Value
End If
Next
Next
End Sub