Gridline Related Properties and the Gridline Object

The Axis object has several properties that relate to gridlines; they are described in the following list:

HasMajorGridlines

Set this read-write property to True to show major gridlines for the axis, or False to hide gridlines. Applies only to primary axes (not secondary axes).

HasMinorGridlines

Set this read-write property to True to show minor gridlines for the axis, or False to hide gridlines. Applies only to primary axes (not secondary axes).

MajorGridlines

This read-only property returns a Gridlines object that represents the major gridlines for the specified axis. Applies only to primary axes (not secondary axes).

MinorGridlines

This read-only property returns a Gridlines object that represents the minor gridlines for the specified axis. Applies only to primary axes (not secondary axes).

Note that the Gridlines object is not a collection object; that is, there is no Gridline object. Instead, the properties of the Gridlines object apply to all of the gridlines for the axis. For instance, the following code adds major gridlines to the category axis and formats these lines:

ActiveChart.Axes(xlCategory, xlPrimary).

HasMajorGridlines = True With ActiveChart.Axes(xlCategory, xlPrimary). MajorGridlines.Border .Color = RGB(0, 0, 255) .LineStyle = xlDot .Weight = xlThick End With

0 0

Post a comment