How do I stop my conditional format code from interfering with each other

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,210
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi everyone,
I get this a lot and cant work out,
I have some conditional foramting coodes and when run on there own work great but when run one after the other I get conditions not set for the last ones?
how can I stop this?

my codes are

VBA Code:
Sub cond2()

Dim MyRange As Range
Set MyRange = Range("C:C")
MyRange.FormatConditions.Add Type:=xlExpression, Formula1:="=IF($C1=""No Description!"",TRUE)"
MyRange.FormatConditions(1).Font.Color = RGB(192, 0, 0) 'red
MyRange.FormatConditions(1).Interior.Color = RGB(255, 255, 0) 'yellow
MyRange.FormatConditions(1).Borders.Color = RGB(192, 0, 0)
MyRange.FormatConditions(1).StopIfTrue = False

MyRange.FormatConditions.Add Type:=xlExpression, Formula1:="=IF($BH1="""",FALSE,IF($BH1=FALSE,TRUE))"
MyRange.FormatConditions(2).Font.Color = RGB(192, 0, 0) 'red
MyRange.FormatConditions(2).Interior.Color = RGB(250, 230, 215) 'light red
MyRange.FormatConditions(2).Borders.Color = RGB(192, 0, 0)
MyRange.FormatConditions(2).StopIfTrue = False
End Sub

Sub cond5()
Dim MyRange As Range
Set MyRange = Range("A:A")
MyRange.FormatConditions.Add Type:=xlExpression, Formula1:="=IF($BF1="""",FALSE,IF($BF1=FALSE,TRUE))"
MyRange.FormatConditions(1).Font.Color = RGB(192, 0, 0) 'red
MyRange.FormatConditions(1).Interior.Color = RGB(250, 230, 215) 'light red
MyRange.FormatConditions(1).Borders.Color = RGB(192, 0, 0)
MyRange.FormatConditions(1).StopIfTrue = False
End Sub

Sub cond10()
Dim MyRange As Range
Set MyRange = Range("A11:G500")
MyRange.FormatConditions.Add Type:=xlExpression, Formula1:="=ISEVEN($AZ11)"
MyRange.FormatConditions(1).Interior.Color = RGB(240, 240, 240) 'light grey
MyRange.FormatConditions(1).Borders(xlTop).Color = RGB(220, 220, 220)
MyRange.FormatConditions(1).StopIfTrue = False

MyRange.FormatConditions.Add Type:=xlExpression, Formula1:="=ISODD($AZ11)"
MyRange.FormatConditions(2).Interior.Color = RGB(230, 230, 230) 'light grey
MyRange.FormatConditions(2).Borders(xlTop).Color = RGB(220, 220, 220)
MyRange.FormatConditions(2).StopIfTrue = False
End Sub
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
You need to set your Conditional Formatting priorities!

It looks like you cond10 code is overwriting the cond5 code, as they are both set to priority 1, and overlap in their ranges (A11:A500).
 
Upvote 0
so do i just change them to 3 and 4?
or is there a way to say set as last? I always do my formating in the order i want them to be?
thanks
Tony
 
Upvote 0
so do i just change them to 3 and 4?
That would be one way.

Really, you should sit down and plan it all out.
What are the different rules you have?
What ranges should they appear in?
What order should they apppear in?

Once you have that "roadmap" completed, that will guide you in how you need to set it up.
 
Upvote 0

Forum statistics

Threads
1,223,931
Messages
6,175,465
Members
452,646
Latest member
tudou

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top