vba 如何将图表最小比例设置为特定值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11195953/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 16:36:14  来源:igfitidea点击:

How to set the chart minimum scale to specific values

excel-vbachartsscalevbaexcel

提问by user1270123

How to set the minimum scale to a specific cell value, where in the cell is not constant. ie: if the minimum scale has to be set to 45, and if the value 45 doesn't always occur in the cell D14?

如何将最小比例设置为特定的单元格值,其中单元格不是恒定的。即:如果最小比例必须设置为 45,并且值 45 并不总是出现在单元格中D14

.Axes(xlCategory, xlPrimary).MinimumScale = 45 ' Constant value

.Axes(xlCategory, xlPrimary).MinimumScale = 45 ' Constant value

回答by Siddharth Rout

To set the minimum scale to the lowest value in the range, use the MINfunction. Now since the range in not in the workbook which has the chart but in the csv file which you are opening, you have to fully qualify the range

要将最小刻度设置为范围内的最小值,请使用该MIN函数。现在,由于范围不在具有图表的工作簿中,而是在您打开的 csv 文件中,您必须完全限定范围

To do that, declare a range object and then set it to the relevant range

为此,声明一个范围对象,然后将其设置为相关范围

Dim Rng As Range

'
'~~> Rest of your code
'
Set wsTemp = wbTemp.Sheets(1)
Set Rng = wsTemp.Range("D3:D30")

'
'~~> Rest of your code
'
.Axes(xlCategory, xlPrimary).MinimumScale = Application.WorksheetFunction.Min(Rng)

HTH

HTH