Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Conditional Format overwrighting previous conditional format
Hi, I am trying to format a sheet with three conditional formats but when I
get to the second Conditional Format it is overwrighting previous conditional format. I don't understand why this is happening. Anyone any ideas? Code added below. Cells.Select Range("A12").Activate Application.CutCopyMode = False Selection.FormatConditions.Delete Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _ Formula1:="=$B$66" With Selection.FormatConditions(1).Font .Bold = True .Italic = False .ColorIndex = 5 End With 'Cells.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, Formula:="=$F$66" ' Selection.FormatConditions.Delete Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _ Formula1:="=$F$66" With Selection.FormatConditions(1).Font .Bold = True .Italic = False .ColorIndex = xlAutomatic End With Thanks in advance. Davie |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Conditional Format overwrighting previous conditional format
When you add the second conditional format, you have the statement
With Selection.FormatConditions(1).Font This is referring to the first format . You need to change it to With Selection.FormatConditions(2).Font to refer to the second format. Hope this helps, Hutch "davethewelder" wrote: Hi, I am trying to format a sheet with three conditional formats but when I get to the second Conditional Format it is overwrighting previous conditional format. I don't understand why this is happening. Anyone any ideas? Code added below. Cells.Select Range("A12").Activate Application.CutCopyMode = False Selection.FormatConditions.Delete Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _ Formula1:="=$B$66" With Selection.FormatConditions(1).Font .Bold = True .Italic = False .ColorIndex = 5 End With 'Cells.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, Formula:="=$F$66" ' Selection.FormatConditions.Delete Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _ Formula1:="=$F$66" With Selection.FormatConditions(1).Font .Bold = True .Italic = False .ColorIndex = xlAutomatic End With Thanks in advance. Davie |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Conditional Format overwrighting previous conditional format
Doh!! So simple to fix. I must have had too much beer last night.
Thanks Tom. "Tom Hutchins" wrote: When you add the second conditional format, you have the statement With Selection.FormatConditions(1).Font This is referring to the first format . You need to change it to With Selection.FormatConditions(2).Font to refer to the second format. Hope this helps, Hutch "davethewelder" wrote: Hi, I am trying to format a sheet with three conditional formats but when I get to the second Conditional Format it is overwrighting previous conditional format. I don't understand why this is happening. Anyone any ideas? Code added below. Cells.Select Range("A12").Activate Application.CutCopyMode = False Selection.FormatConditions.Delete Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _ Formula1:="=$B$66" With Selection.FormatConditions(1).Font .Bold = True .Italic = False .ColorIndex = 5 End With 'Cells.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, Formula:="=$F$66" ' Selection.FormatConditions.Delete Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _ Formula1:="=$F$66" With Selection.FormatConditions(1).Font .Bold = True .Italic = False .ColorIndex = xlAutomatic End With Thanks in advance. Davie |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Conditional format to turn text red after 56 days from previous se | Excel Worksheet Functions | |||
New Conditional Format Overriding Previous Conditional Format | Excel Discussion (Misc queries) | |||
conditional cell format based on cell in same row, previous column | Excel Worksheet Functions | |||
Multiple conditional on conditional format formula | Excel Programming | |||
Keep format after paste from other worksheets - conditional format or EnableControl solution doesn't work | Excel Programming |