IconSets 对象 (Excel)
表示图标 集 条件格式规则中使用的图标集的集合。
使用 IconSetCondition 对象的 IconSet 属性分配条件格式的图标集。 通过将 XlIconSet 枚举的一个常量作为 Workbook 对象的 IconSets 属性的索引传递,将此属性设置为内置图标集之一。 有关详细信息,请参阅示例。
下面的代码示例创建表示测试分数的数字范围,然后将图标集条件格式规则应用于该范围。 图标集的类型将从默认图标变为五箭头图标集。 最后,将阈值类型从百分点修改为硬编码数字。
Sub CreateIconSetCF()
Dim cfIconSet As IconSetCondition
'Fill cells with sample data from 1 to 10
With ActiveSheet
.Range("C1") = 55
.Range("C2") = 92
.Range("C3") = 88
.Range("C4") = 77
.Range("C5") = 66
.Range("C6") = 93
.Range("C7") = 76
.Range("C8") = 80
.Range("C9") = 79
.Range("C10") = 83
.Range("C11") = 66
.Range("C12") = 74
End With
Range("C1:C12").Select
'Create an icon set conditional format for the created sample data range
Set cfIconSet = Selection.FormatConditions.AddIconSetCondition
'Change the icon set to a five-arrow icon set
cfIconSet.IconSet = ActiveWorkbook.IconSets(xl5Arrows)
'The IconCriterion collection contains all IconCriteria
'By indexing into the collection you can modify each criterion
With cfIconSet.IconCriteria(1)
.Type = xlConditionValueNumber
.Value = 0
.Operator = 7
End With
With cfIconSet.IconCriteria(2)
.Type = xlConditionValueNumber
.Value = 60
.Operator = 7
End With
With cfIconSet.IconCriteria(3)
.Type = xlConditionValueNumber
.Value = 70
.Operator = 7
End With
With cfIconSet.IconCriteria(4)
.Type = xlConditionValueNumber
.Value = 80
.Operator = 7
End With
With cfIconSet.IconCriteria(5)
.Type = xlConditionValueNumber
.Value = 90
.Operator = 7
End With
End Sub
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。