Excel Workbook | |||
---|---|---|---|
A | |||
1 | 1 | ||
2 | 1 | ||
Sheet1 |
Cells with Conditional Formatting | ||||
---|---|---|---|---|
Cell | Condition | Cell Format | Stop If True | |
A1 | 1. / Formula is =COUNTIF($A$1:A1,A1)>1 | Abc | ||
A2 | 1. / Formula is =COUNTIF($A$1:A2,A2)>1 | Abc |
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then
HighlightDups
Else
If Cells.Find(What:=Target.Value, After:=[A1], LookIn:=xlValues, LookAt:= _
xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Address = Target.Address Then
Target.Interior.Pattern = xlNone
Else: Target.Interior.Color = RGB(0, 255, 0)
End If
End If
End Sub
Sub Enable()
Application.EnableEvents = True
End Sub
You could use this condition to highlight duplicates in a column, leaving the first one not highlited.
=(MATCH(A1, A:A,0)<>ROW(A1))