VBA code to find 3 values in a range and mark that record as Matched
Hi Experts,
I'm new to VBA/Excel Marcos and i'm building a solution that pulls 3 columns from one excel sheet(Source) and 3 columns from another excel sheet (Target). I need help with VBA code pick 3 columns at a time and search for match in target. In next column mark that cell as "Matched" if match found. If no match highlight source row.
Refer to the attached sample sheet and guide with solution.
Regards
Kumar
Attachment | Size |
---|---|
Sample_Data.xls | 24.5 KB |
See if this one helps Sub
See if this one helps
Sub Leo()
Dim sour As String, tar As String, lr As Long
lr = Range("A" & Rows.Count).End(xlUp).Row
For Each cl In Range("A3", "A" & lr)
sour = cl & cl.Offset(, 1) & cl.Offset(, 2)
tar = cl.Offset(, 4) & cl.Offset(, 5) & cl.Offset(, 6)
If sour = tar Then
cl.Offset(, 7) = "Match"
ElseIf sour <> tar Then
Range("B" & cl.Row, "D" & cl.Row).Interior.ThemeColor = xlThemeColorAccent5
Range("B" & cl.Row, "D" & cl.Row).Interior.TintAndShade = 0.799981688894314
End If
Next
End Sub
Kind regards
Leo