Font

S

sgdav

How do I write a macro or if-then statement to examine the font colour in a
cell and then return a value dependant on the colour?
 
M

Mike

I,m not sure what you mean by return a value dependant on font colour but
determining the colour is easy enough. The code below returns the colourindex
number of the active cell.

Sub FontColor()
MsgBox "The Font Color Index is " & ActiveCell.Font.ColorIndex
End Sub

Mike
 
S

Stefi

This function returns colorindices of the cell given as first argument,
depending on the second argument. If it's TRUE, then returns font colorindex,
if FALSE, returns background colorindex.

Function WhatColor(cella As Range, fontbackgr As Boolean)
Application.Volatile
If fontbackgr Then
WhatColor = cella.Font.ColorIndex
Else
WhatColor = cella.Interior.ColorIndex
End If
End Function

Regards,
Stefi

„sgdav†ezt írta:
 
Top