bertchan2003
Programmer
Hi,
I've recorded a macro for creating a 3D line chart. But whenever I run the macro, it stops at:
ActiveChart.SeriesCollection(1).XValues = "=RiskbyFunc!R4C3:R18C3"
with this error:
Run-time error '1004':
Unable to set XValues property of the Series class
Any clue?
Here is the code recorded in the macro:
Sub Create3DChart()
Charts.Add
ActiveChart.ChartType = xl3DLine
ActiveChart.SetSourceData Source:=Sheets("RiskbyFunc"
.Range("C2:I18"
, _
PlotBy:=xlColumns
While ActiveChart.SeriesCollection.Count > 0
ActiveChart.SeriesCollection(1).Delete
Wend
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = "=RiskbyFunc!R4C3:R18C3"
ActiveChart.SeriesCollection(1).Values = "=RiskbyFunc!R4C6:R18C6"
ActiveChart.SeriesCollection(1).Name = "=""Function 1"""
ActiveChart.SeriesCollection(2).XValues = "=RiskbyFunc!R4C3:R18C3"
ActiveChart.SeriesCollection(2).Values = "=RiskbyFunc!R22C6:R36C6"
ActiveChart.SeriesCollection(2).Name = "=""Function 2"""
ActiveChart.SeriesCollection(3).XValues = "=RiskbyFunc!R4C3:R18C3"
ActiveChart.SeriesCollection(3).Values = "=RiskbyFunc!R40C6:R54C6"
ActiveChart.SeriesCollection(3).Name = "=""Function 3"""
ActiveChart.Location Where:=xlLocationAsObject, Name:="RiskbyFunc"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Release Risk over time at " + "Functional level"
.Axes(xlCategory).HasTitle = True
.Axes(xlCategory).AxisTitle.Characters.Text = "Day"
.Axes(xlSeries).HasTitle = True
.Axes(xlSeries).AxisTitle.Characters.Text = "Risk"
.Axes(xlValue).HasTitle = True
.Axes(xlValue).AxisTitle.Characters.Text = "Functions"
End With
End Sub
Thanks
I've recorded a macro for creating a 3D line chart. But whenever I run the macro, it stops at:
ActiveChart.SeriesCollection(1).XValues = "=RiskbyFunc!R4C3:R18C3"
with this error:
Run-time error '1004':
Unable to set XValues property of the Series class
Any clue?
Here is the code recorded in the macro:
Sub Create3DChart()
Charts.Add
ActiveChart.ChartType = xl3DLine
ActiveChart.SetSourceData Source:=Sheets("RiskbyFunc"
PlotBy:=xlColumns
While ActiveChart.SeriesCollection.Count > 0
ActiveChart.SeriesCollection(1).Delete
Wend
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = "=RiskbyFunc!R4C3:R18C3"
ActiveChart.SeriesCollection(1).Values = "=RiskbyFunc!R4C6:R18C6"
ActiveChart.SeriesCollection(1).Name = "=""Function 1"""
ActiveChart.SeriesCollection(2).XValues = "=RiskbyFunc!R4C3:R18C3"
ActiveChart.SeriesCollection(2).Values = "=RiskbyFunc!R22C6:R36C6"
ActiveChart.SeriesCollection(2).Name = "=""Function 2"""
ActiveChart.SeriesCollection(3).XValues = "=RiskbyFunc!R4C3:R18C3"
ActiveChart.SeriesCollection(3).Values = "=RiskbyFunc!R40C6:R54C6"
ActiveChart.SeriesCollection(3).Name = "=""Function 3"""
ActiveChart.Location Where:=xlLocationAsObject, Name:="RiskbyFunc"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Release Risk over time at " + "Functional level"
.Axes(xlCategory).HasTitle = True
.Axes(xlCategory).AxisTitle.Characters.Text = "Day"
.Axes(xlSeries).HasTitle = True
.Axes(xlSeries).AxisTitle.Characters.Text = "Risk"
.Axes(xlValue).HasTitle = True
.Axes(xlValue).AxisTitle.Characters.Text = "Functions"
End With
End Sub
Thanks