Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set Category (X) axis Lables

Status
Not open for further replies.

bkclaw113

IS-IT--Management
Jun 10, 2002
71
0
0
US
Any suggestions on how to use VBA to set the Category (X) Axis Lables on using VBA?

When creating a line (xlLineMarkers) chart in Excel using VBA I am not able to program the X axis lables. By default my chart just lables the X axis with 1 - n to represent the number of data points. I tried recording a macro when I manually selected "Source Data" - "Series" on the chart, and then entered in the appropriate range for the Category (X) axis Lables, however when I view the records code it only lists the Values for my SeriesCollection items, and does not have any reference to the change of the lables.

 



Hi,

Do you have a range set for the XValues property of the SeriesCollection? This would correspond to the Category Textbox range in the Source Data Tab.

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
I am not have any problems with the XValues property, I am able to set this without issue. I am not able to find an object or property in VBA that controls the Category (X) Axis Labels.
 


SeriesCollection/Axes/Point/DataLable

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 



From HELP
DataLabel Property
See AlsoApplies ToExampleSpecificsReturns a DataLabel object that represents the data label associated with the point or trendline. Read-only.

Example
This example turns on the data label for point seven in series three in Chart1, and then it sets the data label color to blue.

With Charts("Chart1").SeriesCollection(3).Points(7)
.HasDataLabel = True
.ApplyDataLabels type:=xlValue
.DataLabel.Font.ColorIndex = 5
End With


Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
I am not have any problems with the DataLabel, I am able to set these without issue. I am not able to find an object or property in VBA that controls the Category (X) Axis Labels.
 


Something like this...
Code:
    Dim MyArray(1)
    MyArray(0) = "NewLabel1"
    MyArray(1) = "NewLabel2"
    ActiveSheet.ChartObjects(1).Chart.SeriesCollection(1).XValues = MyArray

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top