View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JMay JMay is offline
external usenet poster
 
Posts: 468
Default Change Font Color for Dupes on Selection Change

How about:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column < 4 Then Exit Sub
If Application.WorksheetFunction.CountIf(Range("$D$1: $D$1000"), Target) 1
Then
Target.Interior.ColorIndex = 6
End If
End Sub

" wrote:

For various reasons, I would prefer to use vba as opposed to
conditional formatting for my worksheet. If a duplicate value (in
this case, lengthy text entries) exists, change the font color to
blue. I can successfully write the macro for it but again, I would
prefer that it fire automatically on the Worksheet Selection Change
and I just can't figure how to make that work.

"=COUNTIF($D$1:$D$1000,D1)1"

Any assistance greatly appreciated as always.