Excel) (Databar 物件
代表資料長條設定格式化條件規則。 在範圍內套用資料長條,有助於您檢視相對於其他儲存格時儲存格的值。
所有條件式格式化物件都包含在 FormatConditions 集合物件內,該集合物件是 Range 集合的子系。 您可以使用FormatConditions集合的Add或AddDatabar方法來建立資料橫條格式化規則。
您可以使用Databar物件的MinPoint和MaxPoint屬性來設定資料範圍最短橫條和最長長條的值。 這些屬性會傳回 ConditionValue 物件,您可以使用該物件來指定如何評估閾值。
Databar 物件也會提供屬性,好讓您指定出現負值時要顯示的軸線,以及指定資料橫條的色彩與格式。
下列範例會建立資料範圍,然後將資料橫條套用至該範圍。 您會注意到,因為範圍中有極低和高的值,所以中間值的資料橫條長度類似。 為了釐清中間值的意義,此範例程式碼會使用 ConditionValue 物件來變更閾值求得百分位數的求值方式。
Sub CreateDatabarCF()
Dim cfDatabar As Databar
' Create a range of data with a couple of extreme values
With ActiveSheet
.Range("D1") = 1
.Range("D2") = 45
.Range("D3") = 50
.Range("D2:D3").AutoFill Destination:=Range("D2:D8")
.Range("D9") = 500
End With
Range("D1:D9").Select
' Create a data bar with default behavior
Set cfDatabar = Selection.FormatConditions.AddDatabar
MsgBox "Because of the extreme values, middle data bars are very similar"
' The MinPoint and MaxPoint properties return a ConditionValue object
' which you can use to change threshold parameters
cfDatabar.MinPoint.Modify newtype:=xlConditionValuePercentile, _
newvalue:=5
cfDatabar.MaxPoint.Modify newtype:=xlConditionValuePercentile, _
newvalue:=75
End Sub
- Application
- AppliesTo
- AxisColor
- AxisPosition
- BarBorder
- BarColor
- BarFillType
- Creator
- Direction
- Formula
- MaxPoint
- MinPoint
- NegativeBarFormat
- Parent
- PercentMax
- PercentMin
- Priority
- PTCondition
- ScopeType
- ShowValue
- StopIfTrue
- Type
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。