使用 VBA 的图表绝对位置 [英] Absolute Position of Chart Using VBA

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

问题描述

我可以使用 VBA 使用以下代码创建一个 clustured 柱状图:

I can use VBA to create a clustured column charty using the following code:

ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlColumnClustered

但是,这通常位于我的屏幕中央.我可以使用如下代码移动它:

However this is normally positioned in the centre of my screen. I can have it moved using code such as the following:

ActiveSheet.Shapes("Chart 1").IncrementLeft -650.4545669291
ActiveSheet.Shapes("Chart 1").IncrementTop -295.9091338583

然而,这只是相对于其原始位置.是否可以将其设置为始终位于某个像素或单元格编号?换句话说,我可以编写 VBA 代码以在工作表的某个位置创建图表吗?

However this is only relative to its original position. Is it possible to set it that will always be positioned at a certain pixels or cell number? In other words can I code VBA to have create the chart in a certain position on the worksheet?

推荐答案

使用 .Top.Left 属性
例如

Use the .Top and .Left properties
e.g

With ActiveSheet.Shapes("Chart 1")
    .Left = Range("C10").Left
    .Top = Range("C10").Top
End With

这篇关于使用 VBA 的图表绝对位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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