Compare font colors

G

gary

How can I write a formula to compare the contents of two cells and do
one thing if the font colors are the same and do a different thing if
the font colors are different?
 
D

Don Guillett

How can I write a formula to compare the contents of two cells and do
one thing if the font colors are the same and do a different thing if
the font colors are different?

How did the fonts become colored, manually, or by conditional
formatting?
Also, which version of excel ________?
 
D

Don Guillett

Microsoft Office Excel 2007.

Sub ifManualColor()For Each c In Range("R1:R6")'MsgBox
c.Interior.ColorIndexIf c.Interior.ColorIndex = 36 ThenMsgBox
cElse'whatEnd IfNext cEnd Sub
 
D

Don Guillett

Sub ifManualColor()For Each c In Range("R1:R6")'MsgBox
c.Interior.ColorIndexIf c.Interior.ColorIndex = 36 ThenMsgBox
cElse'whatEnd IfNext cEnd Sub

OK you did ask for font color and a formula. How about a UDF?
Put this in a REGULAR module and then simply use =ic(a2) to check for
blue font

Function ic(x As Range)
If x.Font.ColorIndex = 5 Then
ic = "blue"
Else
ic = "notblue"
End If
End Function
 
D

Don Guillett

Sub ifManualColor()For Each c In Range("R1:R6")'MsgBox
c.Interior.ColorIndexIf c.Interior.ColorIndex = 36 ThenMsgBox
cElse'whatEnd IfNext cEnd Sub

I thought I had posted this. Put in regular module and then =ic(a2) to
check for blue

Function ic(x As Range)If x.Font.ColorIndex = 5 Thenic = "blue"Elseic
= "notblue"End IfEnd Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top