Graph/Chart Change Y-AXIS with Code (1 Viewer)

Daveyk01

Registered User.
Local time
Yesterday, 18:18
Joined
Jul 3, 2007
Messages
144
If you have a chart in a report, and VBA code acumulates data that would go off the pre-set Y-AXIS scale of the chart, is there anyway for that VBA code to change the Y-AXIS Scale Minimum?

On a scale of 0% - 105%, the majority of my data is condensed around 80% +/- 20% so I have the Y-AXIS minimum set to something like .55 (55%).

There is rare instances that the data could go below 55%. Rather that compressing the chart for that rare instance, it would be nice if I could change the Y-AXIS Scale Minimum on the fly?

I have tried this:
Me.ProbeHistogram.Object.Scale.Minimum = AVGMin / 100

but I get an "object doesn't support this property or method" error. So that code must be way off.

Thanks kindly for your helpp
 

Daveyk01

Registered User.
Local time
Yesterday, 18:18
Joined
Jul 3, 2007
Messages
144
After a bunch of fooling around, I tried this and it worked:
Graph_Data.Axes(2).MinimumScale = (AVGMin / 100) - 0.05
 

vaporinc

New member
Local time
Yesterday, 20:18
Joined
Jan 11, 2008
Messages
6
I've been playing with this all day and haven't been able to figure out how to make it work.

I'm trying to adjust the Y-Axis scale

I want to make the Minimum = 2 and the Maximum = 6 and the Major unit = 0.5

How do I do this with code. I have a bunch of datasets which use this chart and have different parameters. I know how to get the values I want to set it to, but cannot figure out how to change the min/max values for the life of me.

I've tried playing with the code above and some other ones. Either the graph will not change the scale or it gives me an error.

When I try using the following code

Code:
Set GraphObj1 = Me![Graph49].Object.Application.Chart 'Graph1 is the name of your chart'
Me.Graph49.Object.Application.Chart.Axes(2).MinimumScale = 0
Me.Graph49.Object.Application.Chart.Axes(2).MaximumScale = 100

I will get the error
Run-time error '2771'
The bound or unbound object frame you tried to edit doesn't contain an OLE object.

I'm so lost, I hope someone can help me solve this issue that I've wasted the last 4 hours trying to fix.
 

Users who are viewing this thread

Top Bottom