共用方式為


Excel) (資料列物件

代表資料長條設定格式化條件規則。 在範圍內套用資料長條,有助於您檢視相對於其他儲存格時儲存格的值。

註解

所有條件式格式設定物件都包含在 FormatConditions 集合物件內,該物件是 Range 集合的子系。 您可以使用 FormatConditions 集合的 AddAddDatabar 方法來建立資料列格式設定規則。

您可以使用 Databar 物件的 MinPointMaxPoint 屬性來設定資料範圍的最短長條和最長長條的值。 這些屬性會傳回 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

方法

屬性

另請參閱

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應