View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.charting
Andy Pope Andy Pope is offline
external usenet poster
 
Posts: 2,489
Default Multiple charts on single chart sheet

Hi Brian,

You missed of your sample code :)

This, in xl2003, creates a chartsheet with 2 chart objects. Assuming active
cell is empty when run the chart and chartobjects will be empty but
visible.

Sub x()

Dim chtHolder As Chart
Dim chtTempA As ChartObject
Dim chtTempB As ChartObject

Set chtHolder = Charts.Add
With chtHolder
Set chtTempA = .ChartObjects.Add(1, 1, 10, 10)
Set chtTempB = .ChartObjects.Add(1, 1, 10, 10)
With .ChartArea
chtTempA.Height = .Height
chtTempB.Height = .Height
chtTempA.Width = .Width / 2
chtTempB.Width = chtTempA.Width
chtTempB.Left = chtTempA.Left + chtTempA.Width
End With
End With

End Sub

Cheers
Andy
--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"Brian Reilly, MVP" wrote in message
...
I would like to place two charts on the same chart sheet via VBA which
I can do.

The problem is in resizing the second chart.

The logic I am using is create a chart sheet with no chart.
Create a chart and place it on the empty chart sheet and size and
place it using .top, .left, .height and .width settings. Works
perfectly.

Now I create the second chart and place it on the same chart sheet. If
I use the same method (different values), the second chart either
sizes incorrectly or disappears all together.

Here's the sample code. I have somethings hard-coded and know better
but I am interested only in the sizing methods to use on multiple
charts on a single page.

Any insights or pointers in the right direction to somewhere that has
examples of this done by VBA?

Brian Reilly, PowerPoint MVP