This code is coloring ( colorindex) that are input values in the times following the first time, and does not coloring the cell that a value is entered first in the case of similarity with other cells
And the desired color of all cells, including the first cell
How can an amendment to this code?
[vba]
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1:B100"
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
Application.ScreenUpdating = False
If Application.CountIf(Me.Range(WS_RANGE), Target.Value2) > 1 Then
If MsgBox("Accept Duplicate?", vbYesNo, "RepeatedValues") = vbYes Then
Target.Interior.ColorIndex = 40
Else
Target.Value2 = ""
End If
Else
Target.Interior.ColorIndex = xlNone
End If
Application.ScreenUpdating = True
End If
End Sub
[/vba]