I'm trying to make an event where I'm matching data from column N of two sheets and if data matches it will do the process of background fill of rows.
the code is as below. while using this I'm getting an error and can't able to put it on loop.
below is the code.
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Set wkbDest = ThisWorkbook
Set wksDest_All = wkbDest.Worksheets("All Leads")
Set wksDest_New = wkbDest.Worksheets("New Leads")
If Not Intersect(Target, Columns.Range("A:AS")) Is Nothing Then
If Application.WorksheetFunction.CountA(Target) = 0 Then
' Not Empty
For Each rw In Target.Row
If VBA.Trim(wksDest_All.Range("N" & rw).Value) = VBA.Trim(wksDest_New.Range("N" & rw).Value) Then
Target.Parent.Range("A" & rw.Row & ":AS" & rw.Row).Interior.ColorIndex = 15
Target.Parent.Range("A" & rw.Row & ":AS" & rw.Row).Borders.LineStyle = xlContinuous
End If
Next rw
'Empty
For Each rw In Target.Rows
If VBA.Trim(wksDest_All.Range("N" & rw).Value) <> VBA.Trim(wksDest_New.Range("N" & rw).Value) Then
Target.Parent.Range("A" & rw.Row & ":AS" & rw.Row).Interior.ColorIndex = 0
Target.Parent.Range("A" & rw.Row & ":AS" & rw.Row).Borders.LineStyle = xlContinuous
End If
Next rw
End If
End If
End Sub
For Each rw In Target.Rows.