LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Thief_
 
Posts: n/a
Default Creating a new chart- why Set NewChart = Charts.Add doesn't work?

I've got the following code:

Charts.Add
Set NewChart = Charts.Add
NewChart.ChartType = xlLineMarkers
NewChart.SetSourceData Source:=rng2Plot, PlotBy:=xlRows
NewChart.Location Whe=xlLocationAsObject, Name:="GraphResults"
With NewChart
.HasTitle = True
.ChartTitle.Characters.Text = Title
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Date"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Num Errors"
End With

The code fails at the line ".HasTitle = True". Viewing the NewChart object
in the Watch window show the object has NO properties, but I don't
understand why since it is dimmed as a chart object. The only way to make
this code work is to change it to:

Charts.Add
Set NewChart = ActiveChart
NewChart.ChartType = xlLineMarkers
NewChart.SetSourceData Source:=rng2Plot, PlotBy:=xlRows
NewChart.Location Whe=xlLocationAsObject, Name:="GraphResults"
With NewChart
.HasTitle = True
.ChartTitle.Characters.Text = Title
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Date"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Num Errors"
End With

Can someone explain why this is so?


--
|
+-- Thief_
|


 
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
Skip some columns when creating a chart MikeJ Charts and Charting in Excel 3 April 15th 05 12:15 AM
Creating a pie chart Val Charts and Charting in Excel 1 January 20th 05 07:12 PM
creating an x,y chart smintey Charts and Charting in Excel 2 December 16th 04 11:11 PM
Creating a dynamic chart Fysh Charts and Charting in Excel 9 December 15th 04 02:52 AM
Creating an x,y coordinate chart smintey Charts and Charting in Excel 2 December 9th 04 04:01 PM


All times are GMT +1. The time now is 11:46 PM.

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

About Us

"It's about Microsoft Excel"