Consulting

Results 1 to 5 of 5

Thread: Changed Named Range of Chart

  1. #1
    VBAX Regular
    Joined
    Aug 2007
    Posts
    6
    Location

    Changed Named Range of Chart

    I'm creating charts dynamically and passing in the Named Range as the SeriesCollection(1).Values. The named range is one row on a datasheet. The chart is created with no problems, but it does not reference the named range as its source. Instead, it has resolved it to a formula reference of cells.
    I also have a combobox that allows the user to change values. In the _change event for the combobox, I'm changing the source of the named range to point to the appropriate row on my datasheet. I thought this would make the chart refresh, but since it is not actually referencing the named range, it does not refresh. If I run the code to create the chart again, it is rebuilt using the new value of the named range, but that seems like excessive overhead.
    How do I make my chartobject keep its reference to a named range so that the chart updates when the named range actually changes to a different row?
    I've seen examples of using Offset and CountA, but either I didn't understand them (a very high probability) or they didn't seem to really apply. They appeared to be geared toward having your data range just grow and the chart seeing the expanded range. I'm changing the source named range to another part of the sheet.
    One other thing is that my charts usually have multiple series (each based off a named range that I need to manipulate as described above.
    Any help is appreciated.
    Thx.
    CraigR

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Craig
    Can you post your workbook? Use Manage Attachents in the Go Advanced section.
    Regards
    MD
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Regular
    Joined
    Aug 2007
    Posts
    6
    Location

    Here's the spreadsheet

    I deleted all the other charts and their code. The one chart is in the Volume_And_Cost_Per_Package module.
    Thx.
    CraigR

  4. #4
    VBAX Master
    Joined
    Jun 2007
    Location
    East Sussex
    Posts
    1,110
    Location
    You can use syntax like this:
    .SeriesCollection(1).Values = "='" & WSD.Name & "'!" & RangeName

    HTH
    Regards,
    Rory

    Microsoft MVP - Excel

  5. #5
    VBAX Regular
    Joined
    Aug 2007
    Posts
    6
    Location

    Thank You

    I had tried this before but I didn't include the equal sign in quotes. This works perfectly.
    Thanks.
    Craig

Posting Permissions

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