I found some VBA code that will apply conditional formatting which uses VB colours and for which I have been reqired so far to apply a fixed range. However, I have encountered some limitations which I am not sure how to overcome.
1) The first condition applies a fill colour when a cell value is null
2) I would like to change the font colour to white when the interior colour is dark.
Ideally I would like to apply conditional formatting only to cells which contain a value and remove the fixed range with a dynamic range. I beleive both these requirements can be achieved by removing the fixed range.
Thanking in advance
1) The first condition applies a fill colour when a cell value is null
2) I would like to change the font colour to white when the interior colour is dark.
Ideally I would like to apply conditional formatting only to cells which contain a value and remove the fixed range with a dynamic range. I beleive both these requirements can be achieved by removing the fixed range.
VBA Code:
Sub WeightConditionalFormatting()
Dim wsDailyRecords As Worksheet
Dim MyRange As Range
Set MyRange = Range("B4:B400")
'First Condition
MyRange.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, Formula2:="71"
MyRange.FormatConditions(1).Interior.Color = vbBlue
'Second Condition
MyRange.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, Formula1:="72", Formula2:="74"
MyRange.FormatConditions(3).Interior.Color = vbYellow
'Third Condition
MyRange.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, Formula1:="74"
MyRange.FormatConditions(4).Interior.Color = vbRed
End Sub
Thanking in advance