I have a chart that draws in data from fixed ranges on multiple sheets. I would like the axis on these charts to automatically fit to the ranges, and to be focussed in on the meaningful range, rather than from zero.
我有一个图表,可以从多张纸上的固定范围中提取数据。我希望这些图表上的轴能够自动适应范围,并集中在有意义的范围内,而不是从零开始。
If possible it would also be great to be able to get this from whole numbers.
如果可能的话,能够从整数中得到这个也很棒。
I have written some code but I cant really get it to easily take the maximum value of each series, only the maximum of one.
我已经编写了一些代码,但我真的无法轻松获取每个系列的最大值,只有最大值。
Any help would be greatly appreciated.
任何帮助将不胜感激。
Thanks, Thomas
1 个解决方案
#1
0
I think you are looking for something like this:
我想你正在寻找这样的东西:
Use the following VBA to adjust the y axis (intentionally left the min / max functions referencing distinct ranges)
使用以下VBA调整y轴(故意留下引用不同范围的最小/最大功能)
Sub Macro1()
ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.Axes(xlValue).MinimumScale = Int(WorksheetFunction.Min(ActiveSheet.Range("$B$2:$B$6,$C$2:$C$6,$D$2:$D$6,$E$2:$E$6")))
ActiveChart.Axes(xlValue).MaximumScale = Int(WorksheetFunction.Max(ActiveSheet.Range("$B$2:$B$6,$C$2:$C$6,$D$2:$D$6,$E$2:$E$6"))) + 1
ActiveChart.Axes(xlValue).MinorUnit = 1
End Sub
Hope this helps
希望这可以帮助
#1
0
I think you are looking for something like this:
我想你正在寻找这样的东西:
Use the following VBA to adjust the y axis (intentionally left the min / max functions referencing distinct ranges)
使用以下VBA调整y轴(故意留下引用不同范围的最小/最大功能)
Sub Macro1()
ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.Axes(xlValue).MinimumScale = Int(WorksheetFunction.Min(ActiveSheet.Range("$B$2:$B$6,$C$2:$C$6,$D$2:$D$6,$E$2:$E$6")))
ActiveChart.Axes(xlValue).MaximumScale = Int(WorksheetFunction.Max(ActiveSheet.Range("$B$2:$B$6,$C$2:$C$6,$D$2:$D$6,$E$2:$E$6"))) + 1
ActiveChart.Axes(xlValue).MinorUnit = 1
End Sub
Hope this helps
希望这可以帮助