Automation Error using Chartobjects

L

looloo

Good Afternoon, I did an extensive search through the archives and
could not find a similar problem. I am trying to manipulate a chart
within a chart. I receive the following error on the last line of
code: automation error 2147221080 (800401a8)

Here is the portion of code where it bombs:
Sub CreateNewTrendChartNew()

Dim trendRng As Range, avgRng As Range, axisRng As Range
Dim data_sheet As Worksheet
Dim columnz900 As Integer
Dim seriesLoop As Integer
Dim Trends_Chart As Chart, TrendAvg_Chart As Chart

Set Weekly_WB = Workbooks("H4.weeklys.test.xls")
Set data_sheet = Weekly_WB.Sheets("DATA")
Set Trends_Chart = Weekly_WB.Charts("Trends")


Trends_Chart.Activate
Charts.Add
ActiveChart.Name = "Trend Averages"
Set TrendAvg_Chart = Weekly_WB.Charts("Trend Averages")
TrendAvg_Chart.ChartType = xlColumnClustered
TrendAvg_Chart.SetSourceData Source:=avgRng, PlotBy:= _
xlColumns
For z = 1 To 12
TrendAvg_Chart.SeriesCollection(1).Delete
Next z
TrendAvg_Chart.SeriesCollection.NewSeries
TrendAvg_Chart.SeriesCollection(1).XValues = axisRng
TrendAvg_Chart.SeriesCollection(1).Values = avgRng
TrendAvg_Chart.Location Where:=xlLocationAsObject, Name:="Trends"
' BOMBS ON THE FOLLOWING LINE
TrendAvg_Chart.Axes(x1Category).TickLabels.NumberFormat = "mmm"

End Sub
 
G

Guest

If your code is indeed as shown, the answer I think is simple: note you have
"Axes(x1Category)" where it should be "Axes(xlCategory)"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top