Set Y(Primary) axis in Chart on VB

SteveInAlabama

Board Regular
Joined
Aug 22, 2002
Messages
94
I want to set the Y axis min and max based on which data source the operator selects.
For an embedded chart in the activesheet, I set dMaxPrimaryY and dMinPrimaryY with Case select, then:
Set oAxis = oCht.Axes(xlPrimary)
With oAxis
.MaximumScale = dMaxPrimaryY
.MinimumScale = dMinPrimaryY
End With
This code doesn't error, but also doesn't change the Y-axis min and max.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

tusharm

MrExcel MVP
Joined
May 28, 2002
Messages
11,029
In your case, by an unfortunate coincidence, you are trying to set the value of the category axis not the value axis.

Check the syntax for the Axes method. It is <pre>expression.Axes(Type, AxisGroup)</pre>See XL VBA help for more.
 

Forum statistics

Threads
1,148,228
Messages
5,745,482
Members
423,953
Latest member
MrC54

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top