Excel) (IconSets 物件
表示圖示集設定格式化條件規則中使用的 圖示集 合。
條件化格式的圖示集是使用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 支援與意見反應。