Page 382 - Writing Excel Macros with VBA, 2nd Edition
P. 382

and so on, we can create a legend with the word "millions" and then change the labels to 1, 2,
3, . . . .
As an example, the code:
Sub DisplayUnitLabel()

     With ActiveChart.Axes(xlValue)
          .DisplayUnit = xlMillions
          .HasDisplayUnitLabel = True
          With .DisplayUnitLabel
                .Caption = "millions"
                .Font.Size = 14
          End With

     End With
End Sub
produces the chart in Figure 21-11. Note that the value axis is labeled with millions as the legend
indicates.

                                    Figure 21-11. Display unit labels

21.6.7 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

                                                  368
   377   378   379   380   381   382   383   384   385   386   387