E
ExcelMonkey
I am comparing font colour with cell interior colour.
When I colour the font black and use a black interior,
the function returns a true value. When I colour the font
white, against a white cell interior, I get an error.
Should I be using color.index instead? Or am I running
into a problem with one of the colours being
xlColorIndexAutomatic. If so, How do I ensure that the
comparison compares like numeric values to create the
correct boolean value for the funtion?
Public Function CellHasSameFontAndInteriorColour(rng As
Range)
Dim FontColour As Integer
Dim InteriorColour As Integer
With rng
FontColour = .Font.Color
InteriorColour = .Interior.Color
If FontColour = InteriorColour Then
CellHasSameFontAndInteriorColour = True
Else
CellHasSameFontAndInteriorColour = False
End If
End With
End Function
When I colour the font black and use a black interior,
the function returns a true value. When I colour the font
white, against a white cell interior, I get an error.
Should I be using color.index instead? Or am I running
into a problem with one of the colours being
xlColorIndexAutomatic. If so, How do I ensure that the
comparison compares like numeric values to create the
correct boolean value for the funtion?
Public Function CellHasSameFontAndInteriorColour(rng As
Range)
Dim FontColour As Integer
Dim InteriorColour As Integer
With rng
FontColour = .Font.Color
InteriorColour = .Interior.Color
If FontColour = InteriorColour Then
CellHasSameFontAndInteriorColour = True
Else
CellHasSameFontAndInteriorColour = False
End If
End With
End Function