获取图表轴值 [英] Get Chart Axis Value

查看:34
本文介绍了获取图表轴值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我意识到您可以使用

.MaximumScale = 
.MinimumScale = 

是否可以获取轴值?

我之所以这样问,是因为这样可以更轻松地自动化获取图表轴的过程,然后向其中添加一个月(而无需将图形轴设置为自动).

I ask this because it would make it easier to automate a process that gets the axis of a chart, then adds a month to it (without setting the graph axis to automatic).

P.S.

我记录了一个更改轴日期的宏,它将日期值设置为 40148 41609 之类的数字.这是什么?

I recorded a macro of changing the axis dates and it set the date values as a number like 40148 or 41609. What is this?

推荐答案

尝试逐步浏览以下代码段.它显示了如何找到Y轴值以及如何对其进行更改.看到里面的一些评论.

Try to step through the following snippet of code. It shows how to find Y axis value and how to change it. See some comments inside.

第一次尝试将图表嵌入工作表中

Sub test_chart()

'get the chart for activesheet
    Dim myCHR As Chart
    Set myCHR = ActiveSheet.ChartObjects(1).Chart

'get Y axis of the chart
    Dim myYA As Axis
    Set myYA = myCHR.Axes(XlAxisType.xlValue)

'get the value
    Debug.Print myYA.MaximumScale
    Debug.Print myYA.MinimumScale

'the same in almost one line
    With ActiveSheet.ChartObjects(1).Chart.Axes(xlValue)
        Debug.Print .MaximumScale
        Debug.Print .MinimumScale
        'change the value
        .MaximumScale = 10
    End With
End Sub

第二次尝试将图表作为单独的表格

Sub test_sheet_chart()

'get the chart for activesheet
    Dim myCHR As Chart
    Set myCHR = Sheets("All SIN 10 Pubs - Unique Users")

'get Y axis of the chart
    Dim myYA As Axis
    Set myYA = myCHR.Axes(XlAxisType.xlValue)

'get the value
    Debug.Print myYA.MaximumScale
    Debug.Print myYA.MinimumScale

'the same in almost one line
    With Sheets("All SIN 10 Pubs - Unique Users").Axes(xlValue)
        Debug.Print .MaximumScale
        Debug.Print .MinimumScale
        'change the value
        .MaximumScale = 10
    End With
End Sub

这篇关于获取图表轴值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆