VinoBob
01-06-2010, 05:42 AM
Hi all !
I recorded inserting a chart, modified it a bit to suit the code i am using it in, and everythings fine, only one method fails, and i dont get it how, because it shouldnt
Dim row As Integer
Dim col As Integer
Dim rng As Range
row = Worksheets(1).Range("A1").CurrentRegion.Rows.Count
col = Worksheets(1).Range("A1").CurrentRegion.Columns.Count
Set rng = Worksheets(1).Range(Cells(1, col), Cells(row, col))
Charts.Add
ActiveChart.ChartType = xl3DPie
ActiveChart.SetSourceData Source:=rng, PlotBy:=xlColumns
ActiveChart.SeriesCollection(1).XValues = "=Work1!R1C1:R" & Trim(str(row)) & "C1"
ActiveChart.Location Where:=xlLocationAsObject, Name:="Work1"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Title"
End With
ActiveChart.HasLegend = False
ActiveChart.SeriesCollection(1).DataLabels.Select '<< this is the one
Selection.AutoScaleFont = True
With Selection.Font
.Name = "Arial"
.FontStyle = "Normal"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 41
.Background = xlTransparent
End With
I get a 1004 runtime error code, and it says that the Select method of the series is wrong.
Whats the solution?
Thanks in advance!
I recorded inserting a chart, modified it a bit to suit the code i am using it in, and everythings fine, only one method fails, and i dont get it how, because it shouldnt
Dim row As Integer
Dim col As Integer
Dim rng As Range
row = Worksheets(1).Range("A1").CurrentRegion.Rows.Count
col = Worksheets(1).Range("A1").CurrentRegion.Columns.Count
Set rng = Worksheets(1).Range(Cells(1, col), Cells(row, col))
Charts.Add
ActiveChart.ChartType = xl3DPie
ActiveChart.SetSourceData Source:=rng, PlotBy:=xlColumns
ActiveChart.SeriesCollection(1).XValues = "=Work1!R1C1:R" & Trim(str(row)) & "C1"
ActiveChart.Location Where:=xlLocationAsObject, Name:="Work1"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Title"
End With
ActiveChart.HasLegend = False
ActiveChart.SeriesCollection(1).DataLabels.Select '<< this is the one
Selection.AutoScaleFont = True
With Selection.Font
.Name = "Arial"
.FontStyle = "Normal"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 41
.Background = xlTransparent
End With
I get a 1004 runtime error code, and it says that the Select method of the series is wrong.
Whats the solution?
Thanks in advance!