Axis Title Object Example

This example ensures the X-axis has a title and sets the X-axis title's caption and formatting:

Sub FormatXAxisTitle()

Dim oCht As Chart, oAT As AxisTitle 'Get the first embedded chart on the sheet Set oCht = ActiveSheet.ChartObjects(1).Chart 'Give the X axis a title oCht.Axes(xlCategory).HasTitle = True 'Get the title

Set oAT = oCht.Axes(xlCategory).AxisTitle 'Format the title With oAT

.AutoScaleFont = False .Caption = "X Axis Title" .Font.Bold = True End With End Sub

0 0

Post a comment