F
Frank & Pam Hayes
I am trying to create some VBA code that will extend a chart data series
from an Array. Google searches on the subject tell me that there is a known
bug that will not allow this. The code fails on the last
ActiveChart.SeriesCollection line. Any ideas for a workaround? Can I read
the array into a range somehow and then use Range with the Extend method?
Can I do this without writing the range somewhere? Here is the basic code
....
'Read all the datapoints into an array
TotalRows = Range("MyChartSeries").Count
Dim MyArray As Variant
ReDim MyArray(1 To TotalRows, 1 To 6)
MyArray = Worksheets("Data").Range("D9").Resize(TotalRows, 6)
'Extend the datapoints
For x = 1 To TotalRows
DataSeries = MyArray(x, 1)
xValue = MyArray(x, 4)
yValue = MyArray(x, 5)
ActiveChart.SeriesCollection(DataSeries).Extend xValue & "," & yValue,
Rowcol:=xlColumns, CategoryLabels:=True
Next x
Thanks,
Frank
from an Array. Google searches on the subject tell me that there is a known
bug that will not allow this. The code fails on the last
ActiveChart.SeriesCollection line. Any ideas for a workaround? Can I read
the array into a range somehow and then use Range with the Extend method?
Can I do this without writing the range somewhere? Here is the basic code
....
'Read all the datapoints into an array
TotalRows = Range("MyChartSeries").Count
Dim MyArray As Variant
ReDim MyArray(1 To TotalRows, 1 To 6)
MyArray = Worksheets("Data").Range("D9").Resize(TotalRows, 6)
'Extend the datapoints
For x = 1 To TotalRows
DataSeries = MyArray(x, 1)
xValue = MyArray(x, 4)
yValue = MyArray(x, 5)
ActiveChart.SeriesCollection(DataSeries).Extend xValue & "," & yValue,
Rowcol:=xlColumns, CategoryLabels:=True
Next x
Thanks,
Frank