Hello all, hope you can help with the following Macro which I have cobbled together but does not seem to work as required.
I want to compare if I2 is greater than/equal to or lower than H2 and colour I2 Green/Amber or Red accordingly. This needs to apply to the length of the report for each available row.
Below is the code I am using which seems to colour random cells.
Thanks in advance for any help.
I want to compare if I2 is greater than/equal to or lower than H2 and colour I2 Green/Amber or Red accordingly. This needs to apply to the length of the report for each available row.
Below is the code I am using which seems to colour random cells.
VBA Code:
Range("A2:L25000").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="IF(=$I2>H2,(COLUMN(I2)))"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions
.PatternColorIndex = xlAutomatic
.Color = 5296274
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=IF($I2=H2,(COLUMN(I2)))"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions
.PatternColorIndex = xlAutomatic
.Color = 49407
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=IF($I2<H2(COLUMN(I2)))"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Thanks in advance for any help.