Hi there

I'm trying to set up a macro to add conditional formatting to a selected cell range. I have the following code, but keep getting user-defined error messages. Please help!:

Dim myrange As Range
Dim myformat As IconSetCondition
Set myrange = Range("D1:E5")
myrange.FormatConditions.Delete
Set myformat = myrange.FormatConditions.AddIconSetCondition
myformat.IconSet = ActiveWorkbook.IconSets(xl3TrafficLights2)
With myformat.IconCriteria(1)
.Type = xlConditionValuePercent
.Value = 3
.Operator = xlLessEqual
End With
With myformat.IconCriteria(2)
.Type = xlConditionValuePercent
.Value = 8
.Operator = xlLess
End With
With myformat.IconCriteria(3)
.Type = xlConditionValuePercent
.Value = 8
.Operator = xlGreat
End With
End Sub