Microsoft Office Tutorials and References
In Depth Information
Setting axis values
Setting axis values
Figure 16-6 shows a worksheet with a line chart that uses the data in column A.
In addition, the sheet has three named cells: AxisMin (D2), AxisMax (D3), and
MajorUnit (D4). The button executes the following macro, which retrieves the data
in the named cells and uses the values as property settings for the Axis object:
Sub SetAxisValues()
With ActiveSheet.ChartObjects(1).Chart.Axes(xlValue)
.MinimumScale = Range(“AxisMin”)
.MaximumScale = Range(“AxisMax”)
.MajorUnit = Range(“MajorUnit”)
End With
End Sub
Figure 16-6: Using a macro to modify axis settings using values stored in cells
This macro accesses the Axes collection of the Chart object. Using the xlValue
argument causes it to use the value axis. As you know, a chart can have additional
axes. The following table shows how to access each of the possible Axis objects in
a chart. Note that specifying xlPrimary as the second argument is optional (if
omitted, xlPrimary is assumed).
Search JabSto ::

Custom Search