Identify Textcolor


Posted by Alexander Kerste on December 19, 2000 7:24 AM

Hello!
Is there an easy way to find out about the color of the text in a cell?
I'm looking for something like

if text-color = black
do something
else do something else

Thank you,
Alex

Posted by cpod on December 19, 2000 7:41 AM

Go to the visual basic editor, insert a module and then paste:

Public Function FontColor(RangeColor As Range)
FontColor = [RangeColor].Font.Color
End Function

Then you can use the function:

FontColor(a1) which will return the numeric ID for the font color (black is 0)



Posted by Alex Kerste on December 20, 2000 5:14 AM

Thank you, it works fine - at least, when I use it directly in an Excel-sheet.
I had to use the direct expression (Textcolor = Cells(RowIndex, ColIndex).Font.Color) and not the moduls to make it work from within a VB-Script, but now everything does very well.
Thanks for the quick help,
Alex