Thread: Placing charts
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
[email protected] paul.robinson@it-tallaght.ie is offline
external usenet poster
 
Posts: 789
Default Placing charts

Oops
This will add as a chart sheet, not embed in a sheet. If you have an
existing chart on a sheet called "DataChart" you could do

Set myChart = Chartobjects("DataChart")

then set its position as before.
If the chart does not already exist you will have to do,

Set myChart = Charts.Add
Set myChart = myChart.Location(Whe=xlLocationasObject,
Name:="myWorkSheet")

where myWorkSheet is the name of the sheet you want the chart on.

regards
Paul

wrote:
Hi
The chart you add is contained within a ChartObject, which is the
Parent object of the Chart, and you need to set the position of that.
So
Set myChart = Charts.Add
With myChart.Parent
.Top = Range("C2").Top
.Left = Range("C2").Left
end with

will put the top left corner of the chart in the top left corner of C2.

regards
Paul

Fabrizio wrote:
I am writing a macro the generates charts onto a new worksheet. I want to be
able to decide in the code where I want to place the charts. How do you do
this? When recording amcro I cannot make the placement exact so how do you
write the proper code? Please help me!