ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   If statement to test font color (https://www.excelbanter.com/excel-discussion-misc-queries/90175-if-statement-test-font-color.html)

Gary

If statement to test font color
 
I have seen this question in reverse on the forum. Usually the question is
to change the font color when criteria is met.

I need to test the font color in order to determine value. I can do it in
code with a for..next loop but I was wondering if it could be done in an if
statement?

Example: If(fontcolor (A2) = "Red", then "Next Day", "Standard")

What would be the syntax?

Thanks for the help.

Bernard Liengme

If statement to test font color
 
Chip has lots on colours; www.cpearson.com
best wishes
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"Gary" wrote in message
...
I have seen this question in reverse on the forum. Usually the question is
to change the font color when criteria is met.

I need to test the font color in order to determine value. I can do it in
code with a for..next loop but I was wondering if it could be done in an
if
statement?

Example: If(fontcolor (A2) = "Red", then "Next Day", "Standard")

What would be the syntax?

Thanks for the help.




PDUK1

If statement to test font color
 
Try this:

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

If Cell.Font.ColorIndex = 3 Then xxxx

Peter





"Gary" wrote:

I have seen this question in reverse on the forum. Usually the question is
to change the font color when criteria is met.

I need to test the font color in order to determine value. I can do it in
code with a for..next loop but I was wondering if it could be done in an if
statement?

Example: If(fontcolor (A2) = "Red", then "Next Day", "Standard")

What would be the syntax?

Thanks for the help.


Gary

If statement to test font color
 
Peter,

Thanks for the quick response.

I may not have been clear. I was looking for a way to enter that same idea
into a cell. Is that possible?

"PDUK1" wrote:

Try this:

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

If Cell.Font.ColorIndex = 3 Then xxxx

Peter





"Gary" wrote:

I have seen this question in reverse on the forum. Usually the question is
to change the font color when criteria is met.

I need to test the font color in order to determine value. I can do it in
code with a for..next loop but I was wondering if it could be done in an if
statement?

Example: If(fontcolor (A2) = "Red", then "Next Day", "Standard")

What would be the syntax?

Thanks for the help.


Chip Pearson

If statement to test font color
 
There is no way within a formula to determine a cell's color,
either background or foreground. You need a VBA function. See the
"Returning The ColorIndex Of A Cell" on
www.cpearson.com/excel/colors.htm .


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Gary" wrote in message
...
I have seen this question in reverse on the forum. Usually the
question is
to change the font color when criteria is met.

I need to test the font color in order to determine value. I
can do it in
code with a for..next loop but I was wondering if it could be
done in an if
statement?

Example: If(fontcolor (A2) = "Red", then "Next Day",
"Standard")

What would be the syntax?

Thanks for the help.




Gary

If statement to test font color
 
Chip,

Thanks for the confirmation. I thought that might be the answer but was
hoping.

"Chip Pearson" wrote:

There is no way within a formula to determine a cell's color,
either background or foreground. You need a VBA function. See the
"Returning The ColorIndex Of A Cell" on
www.cpearson.com/excel/colors.htm .


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Gary" wrote in message
...
I have seen this question in reverse on the forum. Usually the
question is
to change the font color when criteria is met.

I need to test the font color in order to determine value. I
can do it in
code with a for..next loop but I was wondering if it could be
done in an if
statement?

Example: If(fontcolor (A2) = "Red", then "Next Day",
"Standard")

What would be the syntax?

Thanks for the help.






All times are GMT +1. The time now is 07:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com