xl2007 - Reading Values and XValues

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top