April 2006
Beginner
1114 pages
98h 16m
English
Use the Gridlines objects to control the appearance of gridlines on a chart. Use the Axis object’s MajorGridlines and MinorGridlines properties to get a reference to this object. The Gridlines object has the following members:
Application Border Creator Delete Name Parent Select
Use the Axis object’s HasMajorGridlines or HasMinorGridlines to make sure these objects exist before using them. For example, the following code changes the appearance of the major gridlines for the value axis:
Sub FormatGridLines( )
Dim chrt As Chart, ax As Axis, gl As Gridlines
' Get the chart.
Set chrt = ActiveChart
' Get the value axis.
Set ax = chrt.Axes(xlValue, xlPrimary)
' Make sure the gridlines exist.
ax.HasMajorGridlines = True
' Get the gridlines
Set gl = ax.MajorGridlines
' Make them blue.
gl.Border.Color = &HFF0000
' Change the line style.
gl.Border.LineStyle = XlLineStyle.xlDot
End SubRead now
Unlock full access