AOB
Well-known Member
- Joined
- Dec 15, 2010
- Messages
- 652
- Office Version
- 365
- 2016
- 2013
- Platform
- Windows
Hi guys,
I'm trying to programmatically add some conditional formatting to a defined range. There are three rules I need to apply; I can add the first two but struggling with the last one.
The range is columns K through T
The rules should be as follows :
Here is the code that I have used to get the first two rules in place. I can't figure out the formula to use for the third one :
I'm trying to programmatically add some conditional formatting to a defined range. There are three rules I need to apply; I can add the first two but struggling with the last one.
The range is columns K through T
The rules should be as follows :
- If the value in column J is "Original", and all of the cells in K:T are blank, then colour those cells grey
- If the value in column J is "Original", and the value in the cell directly below is different, colour that cell pale red
- If the value in column J is "Update", and the value in the cell directly above is different, colour that cell pale red
Here is the code that I have used to get the first two rules in place. I can't figure out the formula to use for the third one :
Code:
With sht
Set rngCF = .UsedRange.Offset(, 10).Resize(, 10).EntireColumn
With rngCF
.Resize(1, 1).Select
.FormatConditions.Add 2, Formula1:="=AND($J1=""Original"",COUNTA($K1:$T1)=0)"
With .FormatConditions(.FormatConditions.Count)
.Interior.Color = RGB(211, 211, 211)
.StopIfTrue = True
End With
.FormatConditions.Add 2, Formula1:="=AND($J1=""Original"",K1<>K2)"
With .FormatConditions(.FormatConditions.Count)
.Interior.Color = RGB(255, 228, 225)
.StopIfTrue = True
End With
End With
End With