Axis Object and the Axes Collection Example

This example sets the labels for the X-axis (independently of the data that's plotted) and applies some formatting:

Sub FormatXAxis()

Dim oCht As Chart, oAxis As Axis

'Get the first embedded chart on the sheet

Set oCht = ActiveSheet.ChartObjects(1).Chart 'Get it's X axis

Set oAxis = oCht.Axes(xlCategory) 'Format the X axis With oAxis

.CategoryNames = Array("Item 1", "Item 2", "Item 3") .TickLabels.Orientation = 45

.AxisBetweenCategories = True .ReversePlotOrder = False .MinorTickMark = xlTickMarkNone .MajorTickMark = xlTickMarkCross End With End Sub

0 0

Post a comment