Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Problem creatting charts with VBA

Well, through a lot of trial and error I figured a work around for the
SeriesCollection problem and the fatal Excel crash.

First regarding the crash, it turns out if the Excel tab is set to a chart
and you delete it through VBA, Excel crashes. In my subroutine that deletes
old charts I simply change the focus to a sheet first thats not being deleted.

Regarding the SeriesCollection I developed a subroutine that clears the
SeriesCollection and either returns the first series or creates a new one.
SeriesCollection of a new chart is unpredicable. Some times it starts with
one series, sometimes many and sometimes none.

Private Function GetNewSeries(cChart As Chart) As Series
Dim i As Integer
For i = cChart.SeriesCollection.Count To 2 Step -1
cChart.SeriesCollection(i).Delete
Next
If cChart.SeriesCollection.Count = 1 Then
Set GetNewSeries = cChart.SeriesCollection(1)
Else
Set GetNewSeries = cChart.SeriesCollection.NewSeries
End If
End Function


"TheWizEd" wrote:

In Excel 2007, when I create a new chart using Charts.Add I get a chart that
has all the series of a previously created chart. How can I prevent this? I
want a clean slate. I know that in the past I could not avoid having at
least one series when creating a chart. I simply redefine the attributes of
series one. And this seems to be true of 2007 as well.

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
Problem with charts nabil Charts and Charting in Excel 0 March 1st 09 07:27 PM
problem printing charts Brian Charts and Charting in Excel 2 May 16th 08 03:21 PM
Problem with charts ildivino Charts and Charting in Excel 6 July 26th 07 09:28 AM
problem with charts botha822[_7_] Excel Programming 0 August 9th 06 10:16 PM
Odd problem with charts... narrow! rci Excel Programming 0 December 9th 04 05:42 PM


All times are GMT +1. The time now is 02:22 AM.

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"