Icon SetCondition Object Example

This example adds an icon condition that tags a range of values with one of three colored flags:

Sub CreateIconConditions()

Dim oIconCondition As IconSetCondition

'Add an icon set condition

Set oIconCondition = Range("F6:F16").FormatConditions.AddIconSetCondition

'Choose the 3Flags icon set oIconCondition.IconSet = ActiveWorkbook.IconSets(xl3Flags)

'Set the threshold for Green flag; above 80 percent is green. With oIconCondition.IconCriteria(3) .Type = xlConditionValuePercent .Operator = xlGreater .Value = 80 End With

'Set the threshold for Yellow flag; 70 percent and above is yellow. 'Values that qualify for green will not be tagged as yellow. 'Any values that do not qualify for yellow or green will be red. With oIconCondition.IconCriteria(2) .Type = xlConditionValuePercent .Operator = xlGreater .Value = 70 End With

'Show only the flag icons; not the data values oIconCondition.ShowIconOnly = True

End Sub

0 0

Post a comment