Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 453
  • Last Modified:

Changing the Maximum scale for an excel graph as the values change

How to change the maximum Range of a column graph depending on a maximumvalue in a Range of Values.
The problem is sometimes the values are as low as 1000
and sometimes the values are 50,000. When we set the Maximum scale to 50000 the columns are near to zero if the value is 500 or 1000.and the graph doesnt look good.
Can we change this scale depending on the values in a given Range.
0
santhakumari
Asked:
santhakumari
1 Solution
 
Mike-KieswetterCommented:
Have you got the maximum scale set to Auto in the 'Format Axis','Scale' tab?
This should adjust the scale to suit the data.

If not the code to adjust it would be:

    ActiveSheet.ChartObjects("Chart 1").Select
    ActiveChart.Axes(xlValue).MaximumScale = Range("B30")

Where "Chart 1" is the first chart on the sheet and call B30 contains the max value to use.
To get the code to run, you will need to add a button to the sheet and insert the above. (To do this from the menu select 'View' 'Toolbars' 'Visual Basic'
Click the 'contol toolbox' icon, select the button icon and add to the sheet. Double click the button to open up the code window.

hth
Mike
0
 
santhakumariAuthor Commented:
Thank you for the answer . I tried and  it is working.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now