Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for your help, Tony
Regards, Richard -----Original Message----- You need to include an 'Else' statement as the values are mutually exclusive. I think you're testing for each color and not returning the original font back to black:- i.e Sub colortest() If Range("D74") = "A" And _ Range("E74") = "" And Range("F74") = "" Then Range("D75.D176").Select Selection.Font.ColorIndex = 5 Else Selection.Font.ColorIndex = 1 End If If Range("E74") = "B" And _ Range("D74") = "" And Range("F74") = "" Then Range("E75.E176").Select Selection.Font.ColorIndex = 3 Else Selection.Font.ColorIndex = 1 End If If Range("F74") = "C" And _ Range("D74") = "" And Range("E74") = "" Then Range("F75.F176").Select Selection.Font.ColorIndex = 10 Else Selection.Font.ColorIndex = 1 End If End Sub hth, Tony -----Original Message----- Can anyone tell me what is wrong with this code. It colors columns D, E and F with Blue, Red and Green. But I want ONLY ColumnD colored Blue if D75 = "A" and E75 and F75 are blank. ONLY ColumnE colored Red if E75 = "B" and A75 and F75 are blank and ONLY ColumnF colored Green if F75 = "C" and D75 and E75 are blank. As it is all columns are colored. The non colored columns should be black. Is there a better way to write this code? If Range("D74") = "A" And _ Range("E74") = "" And Range("F74") = "" Then Range("D75.D176").Select Selection.Font.ColorIndex = 5 End If If Range("E74") = "B" And _ Range("D74") = "" And Range("F74") = "" Then Range("E75.E176").Select Selection.Font.ColorIndex = 3 End If If Range("F74") = "C" And _ Range("D74") = "" And Range("E74") = "" Then Range("F75.F176").Select Selection.Font.ColorIndex = 10 End If . . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Used drawing colors in shapes....lost default colors for "Fill Col | Excel Discussion (Misc queries) | |||
Worksheet formatting (fill colors & text colors) disappeared | Excel Discussion (Misc queries) | |||
Lost highlighting and font colors; background colors on web pages | Excel Discussion (Misc queries) | |||
Can I sort columns by colors, example - red, green, yellow | Excel Discussion (Misc queries) | |||
Colors of columns after sorting data in the supporting table | Charts and Charting in Excel |