Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Insert a chart on another sheet

I have a macro that copies data from one workbook and then creates a new
workbook with a two data sheets and then I have sheets for the various
charts. When I go to create the charts the charts always end up on the first
sheet in my workbook. Before I create the chart I do the following to goto
the correct sheet:

Sheets("Cond On Temp").Select

Then I have the following:
Charts.Add
ActiveChart.ChartType = xlXYScatterSmooth
ActiveChart.SetSourceData Source:=Sheets("Cond On Temp").Range("A1")
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = "=DataTable!R2C1:R26C1"
ActiveChart.SeriesCollection(1).Values = "=DataTable!R2C3:R26C3"
ActiveChart.SeriesCollection(1).Name = "=DataTable!R1C3"
ActiveChart.Location Whe=xlLocationAsObject, Name:="Cond On Temp"
ActiveChart.HasLegend = True
ActiveChart.Legend.Select
Selection.Position = xlBottom

Cond on Temp is a normal Excel sheet. Why is my chart not being placed on
the correct Excel sheet?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Insert a chart on another sheet

The method Charts.Add will always add a new chart sheet to the workbook. A
chart that is embedded on another sheet is actually in a "container" called a
chartobject. You need to create the chartobject instead of using Charts.Add.
You can create one this way (you need to specify the location and size using
Left, Top, Width and Height):
Dim MyChartObj as ChartObject, MyChart as Chart
Set MyChartObj = Sheets("Cond On Temp").ChartObjects.Add (Left, Top, Width,
Height)
Set MyChart = MyChartObj.Chart
With MyChart
.ChartType = xlXYScatterSmooth
.SetSourceData Source:=Sheets("Cond On Temp").Range("A1")
...etc
End With
--
- K Dales


"Dwaine Horton" wrote:

I have a macro that copies data from one workbook and then creates a new
workbook with a two data sheets and then I have sheets for the various
charts. When I go to create the charts the charts always end up on the first
sheet in my workbook. Before I create the chart I do the following to goto
the correct sheet:

Sheets("Cond On Temp").Select

Then I have the following:
Charts.Add
ActiveChart.ChartType = xlXYScatterSmooth
ActiveChart.SetSourceData Source:=Sheets("Cond On Temp").Range("A1")
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = "=DataTable!R2C1:R26C1"
ActiveChart.SeriesCollection(1).Values = "=DataTable!R2C3:R26C3"
ActiveChart.SeriesCollection(1).Name = "=DataTable!R1C3"
ActiveChart.Location Whe=xlLocationAsObject, Name:="Cond On Temp"
ActiveChart.HasLegend = True
ActiveChart.Legend.Select
Selection.Position = xlBottom

Cond on Temp is a normal Excel sheet. Why is my chart not being placed on
the correct Excel sheet?

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Insert a chart on another sheet

Thanks, that worked.

"K Dales" wrote:

The method Charts.Add will always add a new chart sheet to the workbook. A
chart that is embedded on another sheet is actually in a "container" called a
chartobject. You need to create the chartobject instead of using Charts.Add.
You can create one this way (you need to specify the location and size using
Left, Top, Width and Height):
Dim MyChartObj as ChartObject, MyChart as Chart
Set MyChartObj = Sheets("Cond On Temp").ChartObjects.Add (Left, Top, Width,
Height)
Set MyChart = MyChartObj.Chart
With MyChart
.ChartType = xlXYScatterSmooth
.SetSourceData Source:=Sheets("Cond On Temp").Range("A1")
...etc
End With
--
- K Dales


"Dwaine Horton" wrote:

I have a macro that copies data from one workbook and then creates a new
workbook with a two data sheets and then I have sheets for the various
charts. When I go to create the charts the charts always end up on the first
sheet in my workbook. Before I create the chart I do the following to goto
the correct sheet:

Sheets("Cond On Temp").Select

Then I have the following:
Charts.Add
ActiveChart.ChartType = xlXYScatterSmooth
ActiveChart.SetSourceData Source:=Sheets("Cond On Temp").Range("A1")
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = "=DataTable!R2C1:R26C1"
ActiveChart.SeriesCollection(1).Values = "=DataTable!R2C3:R26C3"
ActiveChart.SeriesCollection(1).Name = "=DataTable!R1C3"
ActiveChart.Location Whe=xlLocationAsObject, Name:="Cond On Temp"
ActiveChart.HasLegend = True
ActiveChart.Legend.Select
Selection.Position = xlBottom

Cond on Temp is a normal Excel sheet. Why is my chart not being placed on
the correct Excel sheet?

Thanks

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
insert sheet tab is not functioning and can't add new sheet LoLo Excel Worksheet Functions 5 April 2nd 23 07:06 PM
How can I insert a chart on a separate sheet on the workbook Bethy Excel Discussion (Misc queries) 1 October 3rd 09 09:20 AM
Can not insert chart in Excel 2007? Chart does not work right? Janis Excel Discussion (Misc queries) 0 June 18th 09 08:31 PM
HELP required: Insert -> Hyperlink -> ???(no CHART sheet name)!!! [email protected] Excel Worksheet Functions 1 April 27th 05 11:48 AM
Inserting a row in sheet A should Insert a row in sheet B, removing a row in Sheet A should remove the corresponding row in sheet B Hannes Heckner Excel Programming 1 March 5th 04 09:10 AM


All times are GMT +1. The time now is 09:45 PM.

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"