DataBar.AxisPosition property (Excel)
Returns or sets the position of the axis of the data bars specified by a conditional formatting rule. Read/write.
Syntax
expression.AxisPosition
expression A variable that represents a DataBar object.
Return value
Remarks
The axis for data bars is displayed only when the AxisPosition property is either xlDataBarAxisAutomatic or xlDataBarAxisMidpoint, and when there are negative values in the range of values specified with a data bar conditional formatting rule.
If the conditional formatting rule is created programmatically, the default value for the AxisPosition property is xlDataBarAxisNone. If the conditional formatting rule is created by using the user interface, the default value for the AxisPosition property is xlDataBarAxisAutomatic.
Example
The following code example selects a range of cells, adds data bar formatting, and then sets the axis position to display in the middle of the cells when negative values are present.
Range("A1:A10").Select
Range("A1:A10").Activate
Set myDataBar = Selection.FormatConditions.AddDatabar
myDataBar.AxisPosition = xlDataBarAxisMidpoint
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.