+ Reply to Thread
Results 1 to 6 of 6

VBA dynamic charts

  1. #1
    Registered User
    Join Date
    12-24-2016
    Location
    Germany
    MS-Off Ver
    Microsoft office 2013
    Posts
    55

    Post VBA dynamic charts

    I have a range consisting of countries on the Y-axis and years on the X-axis (I am tracking the inflation change over time for each country with a line chart). I want to create a dynamic chart for my sample which will update when a new country is added. The data in the range is linked to another source, hence the number of rows can increase or deacrease. I am happy to use VBA. I don't want to turn the country name into a table and make the dynamic chart based on that, because the legend sign on the chart for empty cells don't disappear. When I turn the whole range into a table and build the chart, it does not do the job either, unless I enter new countries and respective data manually. I tried to use OFFSET&COUNTA, but no luck. The latter works only if I add new date (a new year, new column), but not when I add a new country (new row). This is why I think the only way to do is using VBA.


    I will appreciate your help.
    Attached Files Attached Files

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: VBA dynamic charts

    Tables will work. I noticed that you included blank rows in your table. Don't do that. Define the table to be exactly the number of rows for which you have data. Then create the chart based on the table. In the example as you copy / paste new countries to the line immediately below the table, the new country will be added.
    Attached Files Attached Files
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    12-24-2016
    Location
    Germany
    MS-Off Ver
    Microsoft office 2013
    Posts
    55

    Re: VBA dynamic charts

    dflak

    They are working as you rightly mentioned. But when you delete a country, the legend sign (the pink line) on the chart still remains, which looks untidy. I can find a solution to this. Any Ideas?
    Attached Files Attached Files

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: VBA dynamic charts

    It depends on how you remove the row. If you right click on any cell in the row and select Delete -> Table Row, then the line should go away. If you see "Entire Row" instead of "Table Row," It means that you have the data filtered. It will still work, but you will lose any data on the same row. Deleting just the table row removes the table row without removing other data on the same sheet row.
    Attached Images Attached Images

  5. #5
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: VBA dynamic charts

    Here is a better attachment.
    Attached Images Attached Images

  6. #6
    Registered User
    Join Date
    12-24-2016
    Location
    Germany
    MS-Off Ver
    Microsoft office 2013
    Posts
    55

    Re: VBA dynamic charts

    Thank you dflak!!

+ 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 charts
    By devika_1987 in forum Excel Charting & Pivots
    Replies: 6
    Last Post: 12-28-2012, 02:59 AM
  2. [SOLVED] Dynamic Charts
    By HangMan in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 06-20-2012, 10:40 AM
  3. Dynamic Charts
    By st413 in forum Excel General
    Replies: 1
    Last Post: 08-05-2010, 09:45 AM
  4. Dynamic Charts
    By threnody in forum Excel General
    Replies: 0
    Last Post: 06-08-2010, 04:06 AM
  5. Dynamic Charts
    By munchy_cool in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 10-12-2009, 05:02 PM
  6. Make dynamic charts more dynamic
    By Milo in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 04-12-2006, 04:10 AM
  7. Dynamic Charts
    By Brian Sells in forum Excel General
    Replies: 2
    Last Post: 03-15-2005, 09:06 AM
  8. Replies: 0
    Last Post: 01-19-2005, 06:34 AM

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