Results 1 to 2 of 2

Thread: Finding/Changing Range from existing Excel Chart

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    394

    Finding/Changing Range from existing Excel Chart

    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:
    1. For Each oCht As Excel.Chart In oExcel.Workbooks(1).Charts
    2.  
    3.   Dim cnt As Integer = CType(oCht.SeriesCollection, Excel.SeriesCollection).Count
    4.   For i As Integer = 1 To cnt
    5.     oSeries = oCht.SeriesCollection(i)
    6.     x = oSeries.XValues
    7.  
    8.     oRng = CType(CType(oCht.SeriesCollection, Excel.SeriesCollection).Item(i), Excel.Range)
    9.   Next
    10. Next

    BTW, I know how to set the range using

    vb Code:
    1. 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.
    Last edited by campster; Aug 2nd, 2011 at 09:16 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width