LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Match font color works ... but


With a lot of help on another site, the following code was developed t
match the font color of certain cell data on one sheet with matchin
data in a database (i.e. if a name matches one in the database, matc
the font color of the name in the database).

Code 1 (this is inserted on a module and is the subject of my problem
because it uses a dictionary object):


Code
-------------------
Sub Namecolors(RngN As Range, RngD As Range)
Dim dicNames As New Dictionary
Dim c As Range

For Each c In RngN
If dicNames.Exists(c.Value) Then 'name in rngNames exists in dicNames
dicNames.Remove (c.Value) 'delete existing entry to read in new one
End If
dicNames.Add c.Value, c.Font.Color 'read name into dicNames and associate font color value
Next

For Each c In RngD
If dicNames.Exists(c.Value) Then 'cell value exists in dicNames
c.Font.Color = dicNames.Item(c.Value) 'set font color to associated value
Else
c.Font.Color = RGB(0, 0, 0) 'else, set font color to black
End If
Next
End Su
-------------------


Code 2 (inserted on the destination sheet … simply calls the Namecolor
code whenever a change occurs to the specified cells):


Code
-------------------
'Populate cells with matching font color
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range, RngNames As Range, RngDesired As Range

Set RngDesired = Range("A1:D2")
Set RngNames = Worksheets("Extended List").Range("A1:B100")

On Error Resume Next
For Each c In RngDesired ' Cells.SpecialCells(xlCellTypeFormulas)
Call Namecolors(RngNames, RngDesired)
Next c
End Sub
-------------------


This code works great for what I need (i.e. it changes the font color
exactly as advertised). However, I would like it formatted such that i
does not require the use of a Dictionary object (i.e. I’m going to b
using this spreadsheet for communications purposes (i.e. sending it i
e-mails) and not everyone who opens it will have the Microsof
Scripting Runtime enabled (which is required for this code to work) an
I don’t want to have to explain how to enable it every time I send i
out)

--
BrianDP197
-----------------------------------------------------------------------
BrianDP1977's Profile: http://www.excelforum.com/member.php...fo&userid=2911
View this thread: http://www.excelforum.com/showthread.php?threadid=48856

 
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
Conditional Format for font color using font color Jim Excel Worksheet Functions 2 August 29th 09 11:54 AM
Changing Font color based on font type or size John Excel Discussion (Misc queries) 2 February 7th 08 12:50 AM
Default Border, Font Color, and Cell Background Color Elijah Excel Discussion (Misc queries) 1 October 28th 05 04:10 PM
My fill color and font color do not work in Excel Std Edition 2003 chapstick Excel Discussion (Misc queries) 1 September 11th 05 08:48 PM


All times are GMT +1. The time now is 02:03 AM.

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

About Us

"It's about Microsoft Excel"