G
Greg Wilson
You cannot to my knowledge directly querry the XValues or Values from a chart
series. For example, this does NOT work:
Sub test1()
Dim i As Integer
With ActiveSheet.ChartObjects(1).Chart.SeriesCollection(1)
For i = LBound(.XValues) To UBound(.XValues)
Debug.Print .XValues(i)
Next
End With
End Sub
However, if you set a variant to the XValues or Values, it returns an
variant array that you can querry. Prior to xl2007, the following code works:
Sub test2()
Dim arr As Variant
Dim i As Integer
With ActiveSheet.ChartObjects(1).Chart.SeriesCollection(1)
arr = .XValues
For i = LBound(arr) To UBound(arr)
Debug.Print arr(i)
Next
End With
End Sub
I have a large project that obtains the XValues and Values using the above
code (formatted as a function). A couple of staff have upgraded to xl2007 and
this code stopped working. I don't have xl2007 to experiment with. Wondering
if anyone knows of a simple alternative that doesn't resort to either parsing
the series formula or using a cell range and reading the cell values? Maybe
using Application.Transpose and reading the return array? Or maybe I'm
missing something?
As mentioned above, I don't have xl2007 to experiment with. Appreciative of
responses.
Greg
series. For example, this does NOT work:
Sub test1()
Dim i As Integer
With ActiveSheet.ChartObjects(1).Chart.SeriesCollection(1)
For i = LBound(.XValues) To UBound(.XValues)
Debug.Print .XValues(i)
Next
End With
End Sub
However, if you set a variant to the XValues or Values, it returns an
variant array that you can querry. Prior to xl2007, the following code works:
Sub test2()
Dim arr As Variant
Dim i As Integer
With ActiveSheet.ChartObjects(1).Chart.SeriesCollection(1)
arr = .XValues
For i = LBound(arr) To UBound(arr)
Debug.Print arr(i)
Next
End With
End Sub
I have a large project that obtains the XValues and Values using the above
code (formatted as a function). A couple of staff have upgraded to xl2007 and
this code stopped working. I don't have xl2007 to experiment with. Wondering
if anyone knows of a simple alternative that doesn't resort to either parsing
the series formula or using a cell range and reading the cell values? Maybe
using Application.Transpose and reading the return array? Or maybe I'm
missing something?
As mentioned above, I don't have xl2007 to experiment with. Appreciative of
responses.
Greg