PC Review


Reply
Thread Tools Rate Thread

Conditional Format overwrighting previous conditional format

 
 
davethewelder
Guest
Posts: n/a
 
      10th Apr 2008
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 With Quote
 
 
 
 
Tom Hutchins
Guest
Posts: n/a
 
      10th Apr 2008
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 With Quote
 
davethewelder
Guest
Posts: n/a
 
      10th Apr 2008
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional format to turn text red after 56 days from previous se Ash45 Microsoft Excel Worksheet Functions 1 10th Oct 2008 04:46 PM
New Conditional Format Overriding Previous Conditional Format Rene Microsoft Excel Misc 3 27th Feb 2008 06:08 PM
Multiple conditional on conditional format formula Frank Kabel Microsoft Excel Programming 1 27th Jul 2004 06:24 PM
Re: Multiple conditional on conditional format formula Bob Phillips Microsoft Excel Programming 0 27th Jul 2004 05:30 PM
Keep format after paste from other worksheets - conditional format or EnableControl solution doesn't work Microsoft Excel Programming 0 3rd May 2004 12:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:29 AM.