Simple Q about font color

4

43N79W

How do I retrieve a fonts color? Do I access the color index number or is
there a text value that is a property of the font color?

TIA.

-gk-
 
D

DavidC

Each colour has it's own value.
eg this makes the selected cell(S) green. Yellow is 6 and
red is 3.
With Selection.Interior
.ColorIndex = 4
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With

BOL
DavidC
 
3

38N90W

I have no problem setting font properties. I need to access font properties
without changing them

For instance, cell A1 contains a text value. I want something like:

MsgBox Range("A1").Font.ColorIndex

-OR-

a = Selection.Font.ColorIndex


Of course, these don't work.

-gk-
 
J

JE McGimpsey

What "doesn't work" about your statements?

Either will return 1 of the 56 colorindex values, or
xlColorIndexAutomatic (-4105).

Note if the selection contains more than one cell with different font
colors, Selection.Font.ColorIndex returns Null.
 
J

Jarek

Hi,
I think MsgBox Range("A1").Font.ColorIndex works. Try next procedure.

Sub test_colorindex()
For i = 0 To 56
With Range("A1").Offset(i)
.Value = i
.Font.ColorIndex = i
.Offset(, 1).Value = .Font.ColorIndex
End With
Next i
End Sub

Jare
 
3

38N90W

JE McGimpsey said:
What "doesn't work" about your statements?

Either will return 1 of the 56 colorindex values, or
xlColorIndexAutomatic (-4105).

Note if the selection contains more than one cell with different font
colors, Selection.Font.ColorIndex returns Null.


A Ha!

My text in question had different colors, which I hadn't noticed (long story
but a good reason for that).

Seems my problem just a got a bit more complex. Thanks!

-gk-
 
Top