Returning Chart Ranges Inna String

DALeffler

Registered Perpetrator
Local time
Today, 07:38
Joined
Dec 5, 2000
Messages
263
I know how to set a charts source data using VBA as in:

Code:
With ActiveSheet.ChartObjects("Chart 1").Chart
    .SetSourceData Source:=ActiveSheet.Range(Cells(4, 22), Cells(I - 1, 22)), _
        PlotBy:=xlColumns
End With

But how do I return with VBA the range used on the sheet for the source data?

What I'm looking for is a string to be returned along the lines of:

='AHU #5 (TC-B) Supply Air Temp'!$U$4:$V$22

which would tell me the range on the sheet used by the graph on the sheet for it's source data.

Is this possible?
 
Found it!

Debug.Print ActiveSheet.ChartObjects("Chart 1").Chart.SeriesCollection(1).Formula

Returns (in my case):

=SERIES(,'AHU #5 (TC-B) Supply Air Temp'!$U$4:$U$24,'AHU #5 (TC-B) Supply Air Temp'!$V$4:$V$24,1)

It would be nice to get the individual range formulas for the chart values and category labels as shown in the chart Source Data dialog box under the Series tab, but I can continue coding with this!
 

Users who are viewing this thread

Back
Top Bottom