Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Change Font Color for Dupes on Selection Change

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Change Font Color for Dupes on Selection Change

Try something like

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then ' In XL2007, use CountLarge, not Count
Exit Sub
End If
If Target.Text = vbNullString Then
Target.Font.ColorIndex = xlColorIndexAutomatic
Exit Sub
End If
If Application.WorksheetFunction.CountIf( _
Me.Range("A1:A100"), Target.Text) 1 Then
Target.Font.ColorIndex = 3 ' red
Else
Target.Font.ColorIndex = xlColorIndexAutomatic
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)




wrote in message
...
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.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Change Font Color for Dupes on Selection Change

On Sep 6, 9:00*am, "Chip Pearson" wrote:
Try something like

Private Sub Worksheet_Change(ByVal Target As Range)
* * If Target.Cells.Count 1 Then ' In XL2007, use CountLarge, not Count
* * * * Exit Sub
* * End If
* * If Target.Text = vbNullString Then
* * * * Target.Font.ColorIndex = xlColorIndexAutomatic
* * * * Exit Sub
* * End If
* * If Application.WorksheetFunction.CountIf( _
* * * * * * * * Me.Range("A1:A100"), Target.Text) 1 Then
* * * * Target.Font.ColorIndex = 3 ' red
* * Else
* * * * Target.Font.ColorIndex = xlColorIndexAutomatic
* * End If
End Sub

--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
* *ExcelProduct Group
Pearson Software Consulting, LLCwww.cpearson.com
(email on web site)

wrote in message

...



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.- Hide quoted text -


- Show quoted text -


It seems so easy once someone gives you the answer. Hah! Thanks a
million to both of you
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checkbox to change background color, font color and remove/ add bo Sara Excel Discussion (Misc queries) 2 May 1st 23 11:43 AM
change font color TGS New Users to Excel 2 June 22nd 08 10:22 AM
how can I conditionally change font color, or background color? MOHA Excel Worksheet Functions 3 August 21st 06 06:57 PM
How to change the default Border, Font Color, and Cell Color Elijah Excel Discussion (Misc queries) 3 November 2nd 05 11:52 PM
Why doesn't the font color change? Ingeniero1 Excel Programming 8 June 2nd 05 06:28 PM


All times are GMT +1. The time now is 10:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"