Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
IF Statement and Font Color
Is there a way to have an IF statement check a cell and do something
according to the color of the font? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
IF Statement and Font Color
Yes, with VBA (not IF worksheet function). An example:
Sub macro1() If Sheets("Sheet1").Range("A1").Font.ColorIndex = 1 Then Sheets("Sheet1").Range("B1") = "black" ElseIf Sheets("Sheet1").Range("A1").Font.ColorIndex = 3 Then Sheets("Sheet1").Range("B1") = "red" ElseIf Sheets("Sheet1").Range("A1").Font.ColorIndex = 10 Then Sheets("Sheet1").Range("B1") = "green" End If Hth, Merjet |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
IF Statement and Font Color
in xl2003 and earlier, the interior color of a cell can be one of 56 values
or xlnone. if activecell.Interior.ColorIndex = 3 then ' the cells interior is red to see the Colors associated with the colorindex Sub ShowColors() for i = 1 to 56 cells(i,1).Interior.ColorIndex = i cells(i,2).Value = i Next End Sub Note that the user can create a custom palatte in a workbook and map different colors to the 56 available colorindexes. A good discussion of Excel and colors is at http://www.mvps.org/dmcritchie/excel/colors.htm -- Regards, Tom Ogilvy " wrote: Is there a way to have an IF statement check a cell and do something according to the color of the font? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
IF Statement and Font Color
Try something like the following:
If Range("A1").Font.ColorIndex = 3 Then ' red MsgBox "Red Cell" End If -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) wrote in message oups.com... Is there a way to have an IF statement check a cell and do something according to the color of the font? |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
IF Statement and Font Color
missed the "Font" part
If activecell.Font.ColorIndex = 3 then ' font color is red Instead of xlNone for the interior of the cell, the setting is xlautomatic (if you don't want to assign a color, but let excel set it based on the color scheme). -- Regards, Tom Ogilvy "Tom Ogilvy" wrote in message ... in xl2003 and earlier, the interior color of a cell can be one of 56 values or xlnone. if activecell.Interior.ColorIndex = 3 then ' the cells interior is red to see the Colors associated with the colorindex Sub ShowColors() for i = 1 to 56 cells(i,1).Interior.ColorIndex = i cells(i,2).Value = i Next End Sub Note that the user can create a custom palatte in a workbook and map different colors to the 56 available colorindexes. A good discussion of Excel and colors is at http://www.mvps.org/dmcritchie/excel/colors.htm -- Regards, Tom Ogilvy " wrote: Is there a way to have an IF statement check a cell and do something according to the color of the font? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Conditional Format for font color using font color | Excel Worksheet Functions | |||
Changing Font color based on font type or size | Excel Discussion (Misc queries) | |||
Formatting color and font to a logical statement result? | Excel Worksheet Functions | |||
can font color be controled in an IF statement | Excel Worksheet Functions | |||
If statement to test font color | Excel Discussion (Misc queries) |