ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Setting Chart series (https://www.excelbanter.com/excel-programming/320956-setting-chart-series.html)

bj

Setting Chart series
 
I am receving an "Automation error" when running the following cose using
EXCEL as an automation client from ACCESS.

The embedded chart is created normally but I have been unable to set the
data series.

The code works normally untill it starts to set the data series. Any ideas

xl_wkb.Charts(1).ChartType = xlColumnStacked
xl_wkb.Charts(1).Location Whe=xlLocationAsObject,
Name:="qry_Rep-1-01-Output"

Set xl_Chart = xl_wkb.Worksheets(1).ChartObjects(1).Chart
With xl_Chart

For int_Count = 1 To .SeriesCollection.Count
.SeriesCollection(int_Count).Delete
Next

Set rng_Data = xl_wkb.Worksheets(1).Range("A1")
Set rng_Data = rng_Data.CurrentRegion

For int_Count = 3 To rng_Data.Columns.Count ' 3rd column is first
data column
.SeriesCollection.NewSeries
str_Values = "='qry_Rep-1-01-Output'!" &
rng_Data.Columns(int_Count).Offset(1).Address
str_Name = "='qry_Rep-1-01-Output'!" & rng_Data.Cells(1,
int_Count).Address
.SeriesCollection(int_Count - 2).Values = str_Values
.SeriesCollection(int_Count - 2).Name = str_Name
Next int_Count

.SeriesCollection(1).XValues = rng_Data.Columns(1).Address.Offset(1,
rng_Data.Rows.Count - 1)
.HasTitle = True
.ChartTitle.Characters.Text = "Project By Resource Code - Baseline
Data"

With .Axes(xlCategory, xlPrimary)
.HasTitle = True
.AxisTitle.Characters.Text = "Months"
End With
With .Axes(xlValue, xlPrimary)
.HasTitle = True
.AxisTitle.Characters.Text = "People"
End With


All times are GMT +1. The time now is 12:22 AM.

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