Home » excel » excel – How to change Y Axis Min/Max scale values using c#

excel – How to change Y Axis Min/Max scale values using c#

Posted by: admin April 23, 2020 Leave a comment

Questions:

I’m trying to change the Y Axis Scale limits of Excel Chart using C# , the following code works fine on X-axis but struggling to change this to Y-axis.

 Excel.Axis ax = chartPage_1.Axes(Excel.XlAxisType.xlCategory, Microsoft.Office.Interop.Excel.XlAxisGroup.xlPrimary) as Excel.Axis;
 ax.MinimumScale = 0.3;

any help or suggestions would be much appreciated. Thanks.!

How to&Answers:

Instead of XlAxisType.xlCategory, use XlAxisType.xlValue

Here’s the code I’m using:

myChart.Axes(XlAxisType.xlValue).MinimumScale = MIN_SCALE;

Could be that different chart types will/won’t work with this.