LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Why 2 legend entries?

Hi,

I have the following VBA code for Excel 97.

I have also one problem. When I use
ActiveChart.SeriesCollection.NewSeries, Excel will add a new legend
entry. When I use Trendlines.Add, Excel will add another one. How can I
add only the second one?

And the code...


ActiveSheet.ChartObjects("Chart 1").Activate

'Delete old data series (maybe this could be done easier?)
For i = 20 To 1 Step -1
Err.Clear
ActiveChart.SeriesCollection(i).Delete
Err.Clear
Next i

Err.Clear

'Columns 1-20
For i = 1 To 20
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(i).XValues = "=Sheet1!R2C1:R20C1"
ActiveChart.SeriesCollection(i).Values = "=Sheet1!R2C" & i + 1 &
":R20C" & i + 1
ActiveChart.SeriesCollection(i).Name = "=Sheet1!R1C" & i + 1

'Hide diagram
ActiveChart.SeriesCollection(i).Select

With Selection.Border
.Weight = xlThick
.LineStyle = xlNone
End With

With Selection
.MarkerBackgroundColorIndex = xlNone
.MarkerForegroundColorIndex = xlNone
.MarkerStyle = xlNone
.Smooth = False
.MarkerSize = 5
.Shadow = False
End With

'Add trendline
ActiveChart.SeriesCollection(i).Select
ActiveChart.SeriesCollection(i).Trendlines.Add(Typ e:=xlMovingAvg,
Period:=144, Forward:=0, Backward:=0, DisplayEquation:=False,
DisplayRSquared:=False).Select

ActiveChart.SeriesCollection(i).Trendlines(1).Sele ct

With Selection.Border
.ColorIndex = 40 + i
.Weight = xlThick
.LineStyle = xlContinuous
End With

With Selection
.Type = xlMovingAvg
.Period = 200
.Forward = 0
.Backward = 0
.InterceptIsAuto = True
.DisplayEquation = False
.DisplayRSquared = False
.Name = InputBox("String:", "Name of serie " & i,
ActiveChart.SeriesCollection(i).Name)
End With
Next i

 
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
Hide zero entries from legend Michelle Charts and Charting in Excel 3 April 23rd 23 11:48 AM
Legend entries into columns Debbie Charts and Charting in Excel 1 August 20th 08 09:14 PM
Chart Legend Entries BillCPA Excel Discussion (Misc queries) 1 July 27th 05 11:32 PM
Legend Entries nelly Charts and Charting in Excel 2 June 30th 05 01:22 PM
Specifying Legend Entries Joey Chart User Charts and Charting in Excel 1 June 23rd 05 12:34 AM


All times are GMT +1. The time now is 02:21 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"