ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Automation Error using Chartobjects (https://www.excelbanter.com/excel-programming/361094-automation-error-using-chartobjects.html)

looloo

Automation Error using Chartobjects
 
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 Whe=xlLocationAsObject, Name:="Trends"
' BOMBS ON THE FOLLOWING LINE
TrendAvg_Chart.Axes(x1Category).TickLabels.NumberF ormat = "mmm"

End Sub


K Dales[_2_]

Automation Error using Chartobjects
 
If your code is indeed as shown, the answer I think is simple: note you have
"Axes(x1Category)" where it should be "Axes(xlCategory)"
--
- K Dales


"looloo" wrote:

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 Whe=xlLocationAsObject, Name:="Trends"
' BOMBS ON THE FOLLOWING LINE
TrendAvg_Chart.Axes(x1Category).TickLabels.NumberF ormat = "mmm"

End Sub




All times are GMT +1. The time now is 01:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com