How to make font color oppose to cell interior color

  • Thread starter Thread starter narke
  • Start date Start date
N

narke

Hi,

When I changed the cell color to, say, red, I usually have to change
it's font color to, say, white to make it readable, otherwise a black
font on red background is very hard to see. But, for too many cells
with too many different cell colors, it can be very tedious to set font
colors for each of them.

So, I am thinking whether it exists an automatic solution that can set
font color smartly according to its cell color? For example, if the cell
color is 0x00ff00, it's font color can be its reverse color, 0xff00ff.

Is that possible to implement? Thanks.
 
hi, !

switching only between black/white font color does it serve ? (i.e.)

Sub BlackWhiteFontColor()
Dim nCell As Range
For Each nCell In Selection
Select Case nCell.Interior.ColorIndex
Case 1, 5, 9 To 14, 16 To 18, 21, 23, 25, 29 To 32, 41 To 43, 46 To 56
nCell.Font.ColorIndex = 2
Case Else
nCell.Font.ColorIndex = xlColorIndexAutomatic
End Select
Next
End Sub

hth,
hector.

__ OP __
 
hi, !

switching only between black/white font color does it serve ? (i.e.)
Yes.


Sub BlackWhiteFontColor()
Dim nCell As Range
For Each nCell In Selection
Select Case nCell.Interior.ColorIndex
Case 1, 5, 9 To 14, 16 To 18, 21, 23, 25, 29 To 32, 41 To 43, 46 To 56
nCell.Font.ColorIndex = 2
Case Else
nCell.Font.ColorIndex = xlColorIndexAutomatic
End Select
Next
End Sub

It looks almost what I need, thanks! Just one question: why these
colors:
1, 5, 9 To 14, 16 To 18, 21, 23, 25, 29 To 32, 41 To 43, 46 To 56

1) Why not simply 1 to 56?
2) Why choice 56 as a cross line?

Please give me a little more explain. Thanks.
 
Back
Top