Info

The following macro specifies a secondary value (Y) axis for the chart and plots the Xdata series on the secondary Y axis. It results in the chart shown in Figure 10.13:

Sub SecondaryAxisDemo() Dim Cht As Chart Set Cht = Charts("Chart1") Cht.SeriesCollection("Xdata").AxisGroup = 2 End Sub

Figure 10.13

When one series has numbers of a vastly different scale,add a secondary axis to the chart.

Sub SecondaryAxisDemo() Dim Cht As Chart Set Cht = Charts("Chart1") Cht.SeriesCollection("Xdata").AxisGroup = 2 End Sub

Figure 10.13

When one series has numbers of a vastly different scale,add a secondary axis to the chart.

Grid Lines—VBA Name: HasMajorGridlines and HasMinorGridlines

Gridlines are extensions of the axis tick marks. Just as there are major and minor tick marks on the axes, there are also major and minor gridlines. Gridlines help you to estimate the ordinates of a data point lying at some distance from the axis. Depending upon your requirement and taste, you can choose to either display or do away with either or both of the major and minor gridlines. If the gridlines are displayed, you can set the patterns (color, line weight, line style, and so on) of the lines.

The following code removes all gridlines from the chart:

Sub GridlineDemo() Dim Cht As Chart Set Cht = Charts("Chart1") With Cht

With .Axes(xlValue)

.HasMajorGridlines .HasMinorGridlines End With

With Cht.Axes(xlValue) .HasMajorGridlines .HasMinorGridlines End With End With End Sub

False False

False False

0 0

Post a comment