+ Reply to Thread
Results 1 to 6 of 6

Command buttons to change Values in Charts

  1. #1
    Registered User
    Join Date
    08-03-2017
    Location
    Here & There
    MS-Off Ver
    2013
    Posts
    7

    Command buttons to change Values in Charts

    Hi,

    I would like to know how I could use an active x command button to change the values in a chart (Bar chart, doughnut charts, line graphs etc.)

    What I wish to do is that if a user presses Command Button 'A' then the values in charts change according to Table 'A' and when they press Command Button 'B' then the values in charts change according to Table 'B'.

  2. #2
    Valued Forum Contributor
    Join Date
    04-24-2014
    Location
    United States
    MS-Off Ver
    Office 365 ProPlus
    Posts
    853

    Re: Command buttons to change Values in Charts

    Are the 2 tables the same except for the data in them? Say headings, etc?

    If you post a small sample file, I can take a look at it. Essentially you want a button to change the source data of the chart. A quick google search found this code which you can adapt.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-03-2017
    Location
    Here & There
    MS-Off Ver
    2013
    Posts
    7

    Re: Command buttons to change Values in Charts

    Hey thanks for the reply. Yes the two tables are the same

  4. #4
    Registered User
    Join Date
    08-03-2017
    Location
    Here & There
    MS-Off Ver
    2013
    Posts
    7

    Re: Command buttons to change Values in Charts

    Here is a screen shot of what I'm doing. I wasn't sure how I could post an excel file

    MPSZPJX.png

  5. #5
    Forum Contributor
    Join Date
    12-02-2010
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2013, 2016
    Posts
    100

    Re: Command buttons to change Values in Charts

    @RoboRaz

    Here is a super simple workbook I made by googling around and compiling some different bits of code out there plus a new function.

    Let me know if it helps.

    Thanks,

    DarkF1ame
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    08-03-2017
    Location
    Here & There
    MS-Off Ver
    2013
    Posts
    7

    Re: Command buttons to change Values in Charts

    Quote Originally Posted by ptmuldoon View Post
    Are the 2 tables the same except for the data in them? Say headings, etc?

    If you post a small sample file, I can take a look at it. Essentially you want a button to change the source data of the chart. A quick google search found this code which you can adapt.

    Please Login or Register  to view this content.
    Hey man thanks it's starting to work. I had to change the code a bit for it to work for me:

    Dim CHARTDATA As Range
    Set CHARTDATA = Range(Range("AO42"), Range("AO42").Offset(0, 1).End(xlDown))
    ActiveSheet.ChartObjects("Chart 1").Chart.SetSourceData Source:=CHARTDATA
    Would you please break down the code so I could get the story behind it? I don't quite understand this Range as just "C22". What if I want to limit the number of rows in my table, how would I do that? For example, if I have the Total (Sum) at the bottom of the table but I don't want to show it in my chart, then how would I go about it?

    Also does this mean that I'll have to have a table in separate columns (one beside the other)? I mean to say that it can't have tables one beneath the other? If I have two command buttons, one for each table which would change the values in the bar chart.
    Last edited by RoboRaz; 08-15-2017 at 05:11 PM.

+ 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. Replies: 0
    Last Post: 02-05-2014, 12:34 AM
  2. Change font size on command buttons with VBA
    By ratdogexcel in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-10-2013, 03:46 AM
  3. Useform Code - 12 Command Buttons dependant on other command buttons
    By darrenkaye in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-20-2013, 10:58 AM
  4. Code for a master command button to change the backcolor of multiple command buttons?
    By panttherm5 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-16-2012, 10:11 PM
  5. [SOLVED] Change listbox link cell with command buttons
    By zplugger in forum Excel General
    Replies: 1
    Last Post: 08-12-2012, 06:43 PM
  6. Change Color on Command Buttons
    By nury786 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-02-2012, 12:35 PM
  7. Change Background Color of All Command Buttons
    By CharlesM in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-14-2012, 03:20 AM
  8. Loop to change command buttons
    By stoney1977 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-16-2010, 02:46 PM

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