Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 24
Default Multiple charts on single chart sheet

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

  #2   Report Post  
Posted to microsoft.public.excel.charting
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


  #3   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 6,582
Default Multiple charts on single chart sheet

Hi Brian -

You've left out your code...

I ran the following procedu

Sub TwoChartsOnAChart()

Dim chtParent As Chart
Dim chtob1 As ChartObject
Dim chtob2 As ChartObject

Set chtParent = Charts.Add
With chtParent
Do Until .SeriesCollection.Count = 0
.SeriesCollection(1).Delete
Loop

Set chtob1 = .ChartObjects.Add _
(.ChartArea.Width * 0.1, .ChartArea.Height * 0.2, _
.ChartArea.Width * 0.35, .ChartArea.Height * 0.6)
With chtob1.Chart
.SetSourceData Source:=Worksheets(1).Range("Range1")
End With

Set chtob2 = .ChartObjects.Add _
(.ChartArea.Width * 0.55, .ChartArea.Height * 0.2, _
.ChartArea.Width * 0.35, .ChartArea.Height * 0.6)
With chtob2.Chart
.SetSourceData Source:=Worksheets(1).Range("Range2")
End With
End With
End Sub

The first chart was drawn as expected, but the second was too tall and wide,
too far to the right, and too low. I could insert this (inside the With
chtParent block) after creating the two charts:

With .ChartArea
chtob1.Left = .Width * 0.1
chtob1.Width = .Width * 0.35
chtob1.Top = .Height * 0.2
chtob1.Height = .Height * 0.6

chtob2.Left = .Width * 0.55
chtob2.Width = .Width * 0.35
chtob2.Top = .Height * 0.2
chtob2.Height = .Height * 0.6
End With

but I discovered that inserting DoEvents after creating the first chart and
before creating the second makes both charts work as expected, without
having to go back and resize.

Post back if this isn't what you meant.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services, Inc.
774-275-0064
208-485-0691 fax

http://PeltierTech.com/
_______


"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



  #4   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 24
Default Multiple charts on single chart sheet

Thanks Andy and Jon,
This pints me in the right direction. Sorry about leaving out the
code. Meant to include it.

Brian Reilly, PowerPoint MVP

On Wed, 17 Oct 2007 09:52:10 -0400, "Brian Reilly, MVP"
wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I set up a single header for a multiple sheet workbook? bmace2 Excel Discussion (Misc queries) 2 October 20th 06 10:56 PM
Multiple Chart on Single Page BT Charts and Charting in Excel 4 March 10th 06 09:24 PM
Multiple sheets as data for a single sheet Newbie1092 Excel Worksheet Functions 1 December 19th 05 05:20 PM
How to draw the multiple chart in single sheet. ramkumar_cpt Charts and Charting in Excel 3 November 10th 05 04:07 AM
How do i group together different charts into a single chart in e. Mukund Charts and Charting in Excel 2 February 14th 05 02:46 PM


All times are GMT +1. The time now is 08:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"