热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

vba图表系列动态轴多系列-vbachartseriesdynamicaxismultipleseries

Ihaveachartthatdrawsindatafromfixedrangesonmultiplesheets.Iwouldliketheaxisonthe

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:

我想你正在寻找这样的东西:

Sample

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

希望这可以帮助


推荐阅读
author-avatar
karen_8009
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有