+ Reply to Thread
Results 1 to 2 of 2

VBA - Named ranges in an excel chart

  1. #1
    Registered User
    Join Date
    03-14-2012
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    14

    VBA - Named ranges in an excel chart

    Hi there,

    I'm no programming expert but I have a basic understanding of VBA.

    What I'm trying to achieve is essentially a dynamic chart. I have created a drop down menu which will select data based on the value of the drop down menu.

    The data is being pulled from cells, which is currently in laid out like a table with category down the side, and time periods across the top. The chart should contain all categories, but then the periods displayed in the chart needs to be dependent on the selection from the drop down menu.

    I know how to hard core this, for example:
    If the user selects the time period '2000' then:
    Please Login or Register  to view this content.
    if the user selects the time period '2001' then:
    Please Login or Register  to view this content.
    The above works fine, but the problem is these tables often moved and columns are always removed / added. I've written some code to identify the range I need and store it in a name range.

    I then tried the following:
    Please Login or Register  to view this content.
    'category refers '$B$10:$B$19' and timeperiods refers to 'Q$10:$AD$19'.

    The problem is, it selects everything between B10 and AD19 so column C, D, E... etc are all showing in the chart.

    Is there any way, using the named ranges that I listed above to have the chart only show the columns in the ranges?

    I greatly appreciate any help that anyone can offer on this as I've been stumped on it for some time!

    Thanks in advance.

    Ash
    Last edited by revenge4ash8; 12-12-2014 at 09:13 AM.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: VBA - Named ranges in an excel chart

    Use Union.
    Depending on what category and timeperiods are (it was not really clear for me):
    a) named ranges (Ctrl+F3 in workbook):
    Please Login or Register  to view this content.
    b) variables of range type (dim category as Range ....)
    Please Login or Register  to view this content.
    Best Regards,

    Kaper

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] dynamic chart with named ranges
    By a.hudrea in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-22-2014, 05:18 AM
  2. Excel 2010 Dynamic Chart with named Ranges
    By PaulJGallagher in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 05-03-2013, 09:06 AM
  3. Dynamic Chart Using Named Ranges
    By jjcgirl in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-07-2013, 11:57 AM
  4. Named Data Ranges & Chart
    By Luignata in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-14-2008, 12:50 PM
  5. Named Ranges for Chart
    By Sami82 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-04-2006, 09:17 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1