在Excel中将x轴的最大值和最小值设置为日期 [英] Setting maximum and minimum values for x-axis as dates in Excel

查看:385
本文介绍了在Excel中将x轴的最大值和最小值设置为日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在x轴上具有日期的图形,并且我正在尝试使用Excel VBA设置该轴的最大值和最小值.以下是我的似乎无效的代码.任何人都可以帮忙.

I have a graph that has dates on the x-axis and I'm trying to set maximum and minimum values for this axis using an Excel VBA. Below is my code which doesnt seem to work.Can anyone please help.

With ActiveSheet.ChartObjects(1).Chart.Axes(xlValue)
    .MinimumScale = ActiveSheet.Range("C33").Value
    .MaximumScale = ActiveSheet.Range("D54").Value
End With

推荐答案

xlValue指y轴(或值轴).您对调整需要xlCategory的x轴值(或类别轴)感兴趣.所以用

xlValue refers to the y-axis (or value axis). You're interested in adjust the x-axis values (or category axis) which require xlCategory. So use

With ActiveSheet.ChartObjects(1).Chart.Axes(xlCategory)
    .MinimumScale = ActiveSheet.Range("C33").Value
    .MaximumScale = ActiveSheet.Range("D54").Value
End With

这篇关于在Excel中将x轴的最大值和最小值设置为日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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