VBA Code:
Private Sub worksheet_SelectionChange(ByVal Target As Range)
Dim RngRow As Range
Dim FndRng As Range
Dim Rng As Range
Dim RowRng As Range
'ActiveSheet.Unprotect
Selection.Worksheet.Cells.FormatConditions.Delete
Set FndRng = Intersect(Target, Range("A2:G1000"))
If Not FndRng Is Nothing Then
Set RngRow = Range("A2:G1000")
ActiveCell.FormatConditions.Add xlExpression, , True
ActiveCell.FormatConditions(1).Interior.Color = RGB(0, 0, 255)
Rows(ActiveCell.Row).FormatConditions.Add xlExpression, , "TRUE"
Rows(ActiveCell.Row).FormatConditions(2).Interior.Color = RGB(255, 0, 0)
End If
Set Rng = Intersect(Target, Range("H2:DW1000"))
If Not Rng Is Nothing Then
Set RowRng = Range("H2:DW1000")
ActiveCell.FormatConditions.Add xlExpression, , True
ActiveCell.FormatConditions(1).Interior.Color = RGB(128, 458, 128)
Rows(ActiveCell.Row).FormatConditions.Add xlExpression, , "TRUE"
Rows(ActiveCell.Row).FormatConditions(2).Interior.Color = RGB(255, 0, 0)
End If
End Sub
I set conditional formatting for finding duplicate values but these codes remove my conditional formatting, I wan these codes and also need conditional formatting.