Hi Guys
I hope that somebody can help please. I am trying to create a macro that can compare data between 2 sheets I found this macro below and it works nicely. However I am hoping to modify it and I need help. As below it checks the data in column A, B, C against sheet2 column A, B, C ect. If it does not match the data is written to "unmatched" sheet. What I would to do is add a comment in column J that says which column did not match.
For i = 2 To LastRowSrc
For J = 2 To LastRowData
Found = False
Temp1 = Src1SH.Cells(i, "A") & Src1SH.Cells(i, "B") & Src1SH.Cells(i, "C") & Src1SH.Cells(i, "D") & Src1SH.Cells(i, "F")
Temp2 = Data1SH.Cells(J, "A") & Data1SH.Cells(J, "B") & Data1SH.Cells(J, "C") & Data1SH.Cells(J, "D") & Data1SH.Cells(J, "F")
If (Temp1 = Temp2) Then
Src1SH.Range(Src1SH.Cells(i, "A"), Src1SH.Cells(i, "H")).Interior.ColorIndex = 4
Data1SH.Range(Data1SH.Cells(J, "A"), Data1SH.Cells(J, "H")).Interior.ColorIndex = 4
Found = True
Exit For
End If
Next J
If (Not (Found)) Then
LastRowStore = LastRowStore + 1
Src1SH.Range(Src1SH.Cells(i, "A"), Src1SH.Cells(i, "I")).Copy Destination:=StoreSH.Cells(LastRowStore, "A")
End If
Next I
Regards
Jordan
I hope that somebody can help please. I am trying to create a macro that can compare data between 2 sheets I found this macro below and it works nicely. However I am hoping to modify it and I need help. As below it checks the data in column A, B, C against sheet2 column A, B, C ect. If it does not match the data is written to "unmatched" sheet. What I would to do is add a comment in column J that says which column did not match.
For i = 2 To LastRowSrc
For J = 2 To LastRowData
Found = False
Temp1 = Src1SH.Cells(i, "A") & Src1SH.Cells(i, "B") & Src1SH.Cells(i, "C") & Src1SH.Cells(i, "D") & Src1SH.Cells(i, "F")
Temp2 = Data1SH.Cells(J, "A") & Data1SH.Cells(J, "B") & Data1SH.Cells(J, "C") & Data1SH.Cells(J, "D") & Data1SH.Cells(J, "F")
If (Temp1 = Temp2) Then
Src1SH.Range(Src1SH.Cells(i, "A"), Src1SH.Cells(i, "H")).Interior.ColorIndex = 4
Data1SH.Range(Data1SH.Cells(J, "A"), Data1SH.Cells(J, "H")).Interior.ColorIndex = 4
Found = True
Exit For
End If
Next J
If (Not (Found)) Then
LastRowStore = LastRowStore + 1
Src1SH.Range(Src1SH.Cells(i, "A"), Src1SH.Cells(i, "I")).Copy Destination:=StoreSH.Cells(LastRowStore, "A")
End If
Next I
Regards
Jordan