【发布时间】:2012-01-24 18:03:40
【问题描述】:
我可以通过创建一个空图表表,然后将图表的位置设置为该空图表表,将多个图表放在一个图表表上。
'This creates multiple charts within a single chart sheet!
Charts.Add 'Creates empty chart page when empty cell is selected
'Keep track of chart page for later reference
Dim chartSheet As String
chartSheet = ActiveChart.Name
.... 'Create three separate charts with data here
'Now place these charts within our empty chart page
Set chart1 = chart1.Location(Where:=xlLocationAsObject, Name:=chartSheet)
Set chart2 = chart2.Location(Where:=xlLocationAsObject, Name:=chartSheet)
Set chart3 = chart3.Location(Where:=xlLocationAsObject, Name:=chartSheet)
到目前为止,所有代码都可以正常工作。图表表包含所有 3 个图表,尽管这些图表都是重叠的。当我尝试调整图表的位置时...
'This code fails to run!
chart1.Parent.Top = 0
chart1.Parent.Left = 0
代码返回对象不支持此属性或方法的运行时错误。我知道可以通过单击和拖动来手动移动图表,并且我知道如果图表在正常工作表中,上面的代码就可以工作。但由于某种原因,当图表位于图表表中时,此代码会失败。有什么方法可以让 VBA 做我想做的事吗?
感谢您的帮助。
【问题讨论】: