+ Reply to Thread
Results 1 to 9 of 9

Make the scale of one chart dependent on the scale of another chart

  1. #1
    Registered User
    Join Date
    03-13-2014
    Location
    Miami
    MS-Off Ver
    Excel 2010
    Posts
    42

    Make the scale of one chart dependent on the scale of another chart

    Hi,

    I was wondering if anyone might know how to make a code that changes the x axis range of a chart to match the x axis range of another chart. I'm thinking along the following line:

    1. chart 1 would have a x axis with a particular range (say 1 to 10) which would be preset by the range of the data that is being graphed

    2. chart 2 would use a different data set with a different range (say from -5 to 5).

    3. Excel would normaly make a chart that best fits the range of data, and the range would be different for both charts.

    4. For chart 2 what I would want the display range to be someting like this:

    With ActiveChart
    .Axes(xlValue).MinimumScale = 'here would be a variable that gets the minimum scale from chart 1
    .Axes(xlValue).MinimumScale = 'here would be a variable that gets the maximum scale from chart 1
    End With

    5. I would want to make it so that if the data range from chart 1 changes, the range in chart 2 would change automatically. The range for chart 1 would be predetermined by excel based on the data.

    thanks

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,947

    Re: Make the scale of one chart dependent on the scale of another chart

    Please Login or Register  to view this content.

    You could use the worksheet's calculate event or change event to make the code run.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Make the scale of one chart dependent on the scale of another chart

    Rather than code why not add an additional series to each chart that contains min and max value of both data sets. That way excel will set both charts automatically to the same autoscale properties
    Cheers
    Andy
    www.andypope.info

  4. #4
    Registered User
    Join Date
    03-13-2014
    Location
    Miami
    MS-Off Ver
    Excel 2010
    Posts
    42

    Re: Make the scale of one chart dependent on the scale of another chart

    Hi Bernie,

    sorry for the delay.

    your code works great, except for one thing. I have the "chart1" data linked to a pivot table that I can change the data range with a slicer, so if I change the slicer selection, the second chart won't change, unless I have a separate action button to update the scale second chart. is there a way to link your code to the selection in the slicer? I would like to be able to make a selection in the slicer, and update both charts...

    Thanks.

  5. #5
    Registered User
    Join Date
    03-13-2014
    Location
    Miami
    MS-Off Ver
    Excel 2010
    Posts
    42

    Re: Make the scale of one chart dependent on the scale of another chart

    Hi Andy,

    Im not sure that would work, because I have the data for the first chart in a pivot table...
    Thanks for the help though...

  6. #6
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,947

    Re: Make the scale of one chart dependent on the scale of another chart

    Sure - just use the PivotTableUpdate event to call the macro: in the codemodule of the sheet with the pivot table

    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,947

    Re: Make the scale of one chart dependent on the scale of another chart

    Oops - I replied to myself initially...

    Sure - just use the PivotTableUpdate event to call the macro: in the codemodule of the sheet with the pivot table

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    03-13-2014
    Location
    Miami
    MS-Off Ver
    Excel 2010
    Posts
    42

    Re: Make the scale of one chart dependent on the scale of another chart

    Oh. Thanks Bernie!

    I didnt know it was possible to do that! It's an Awesome trick that's going to eliminate some 50 lines of code for me.

    Do you also know if its possible to program a pivot table slicer so that a person cannot select more than 1 item at a time? (ie, they wouldn't be able to use the shift key or the control key and select multiple items). I can do it with an action button, but I would like to be able to do it by clicking on the slicer.

    thanks!

  9. #9
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Make the scale of one chart dependent on the scale of another chart

    See Bob Phillips' recent article in single choice slicers
    http://wessexbi.wordpress.com/2014/0...-slice-please/

+ 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. Scale Chart on Chart Sheet???
    By ariafxx in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 01-02-2011, 08:25 PM
  2. chart scale
    By Gia in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 06-30-2006, 12:50 AM
  3. [SOLVED] Huge differences in chart values screws my bar chart scale up.
    By Sirritys in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 06-13-2006, 05:35 AM
  4. [SOLVED] Scale in a chart
    By tony in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 05-19-2006, 08:30 PM
  5. [SOLVED] how can I make a chart with the x-axis in logarithmic scale
    By Doris in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 01-17-2005, 12:06 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