Consulting

Results 1 to 4 of 4

Thread: How to get the series range of a chart ...

  1. #1

    How to get the series range of a chart ...

    Hi All,

    I have a chart with one SeriesCollection. I want to get the range of cells for Y-Axis and X-Axis for this chart using VBA.
    The Series object has 'Values' and 'XValues' properties that return the values in an array.
    Is there any way that I can get the range of cells (cell addresses) for the Series?
    Or is there a way to get the range address on the worksheet from the array values?
    Thanks in advance

  2. #2
    VBAX Expert CatDaddy's Avatar
    Joined
    Jun 2011
    Posts
    581
    Location
    [vba]Dim cA() As Variant
    Dim i as integer
    Dim cell as Range
    i=0

    For each cell in Range(somerange)
    cA(i) = cell.Address
    i = i + 1
    Next cell

    Worksheets(1).ChartObjects(1).Chart. _
    SeriesCollection.Extend cA[/vba]

    untested
    ------------------------------------------------
    Happy Coding my friends

  3. #3
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    According to John Walkenbach: "Excel's object model has a serious flaw: There is no direct way to to use VBA to determine the ranges used in a chart."
    You can explore parsing the series formula, or use his class module.
    See:
    http://spreadsheetpage.com/index.php..._chart_series/
    http://www.j-walk.com/ss/excel/tips/tip83.htm
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  4. #4
    Thanks for the replies.
    For a simple chart, the Formula for the Series can be parsed to get the range, but for a chart that uses filtered values from a large dataset, the process gets really complicated.
    For the present, we have to accept the limitation and do the best we can.

Posting Permissions

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