I have an Excel template that contains numerous pre-defined charts and a program that opens this template and collects data used to populate the charts. This works great but I now want to adjust the series length so that the charts only used the data collected (not a range of 32000). I'm trying to iterate through the charts and determine the range for each series of each chart but not having much luck. The snippet below allows me to see the xvalues but does not return any information as to where this data is located.
Does anyone know how to extract the range for each series in a chart?
vb Code:
For Each oCht As Excel.Chart In oExcel.Workbooks(1).Charts Dim cnt As Integer = CType(oCht.SeriesCollection, Excel.SeriesCollection).Count For i As Integer = 1 To cnt oSeries = oCht.SeriesCollection(i) x = oSeries.XValues oRng = CType(CType(oCht.SeriesCollection, Excel.SeriesCollection).Item(i), Excel.Range) Next Next
BTW, I know how to set the range using
vb Code:
oCht.SetSourceData(oShtData.Range(strRng), Excel.XlRowCol.xlColumns)
The problem is that I need to know the current range so that I can simply modify the max length of the series.




Reply With Quote