PC Review


Reply
Thread Tools Rate Thread

Chart Legend Names

 
 
Andreww
Guest
Posts: n/a
 
      26th Jun 2007
Hi - I have code which, when a user clicks a button, a graph has a
series added to it, then when clicks again it deletes the range.

My series name is incrementally based on which of a series of buttons
is clicked eg if first button is clicked I get series 3 added, 2nd
series 5 and so on.

The series named are based on the button index. The trouble is that as
the legend names are A3, A4,.... A"N" these going to confuse users. (I
add an"A").

The simplest things seems to be to delete the individual legend
entries but VBA doesn't seem to have called the legend entry the same
thing as the series.

Any ideas?

Thanks

Code below:

Sub add_indiv_chart_series()
Dim btn As Button
Dim mText As String
Dim btnText, btnIndex, sitInCell As Variant

'Find out which button clicked
btnIndex = ActiveSheet.Buttons(Application.Caller).Index

' Add chart series on click - if button text is "+" adds series if
"-" deletes
If ActiveSheet.Buttons(Application.Caller).Text = "+" Then
ActiveSheet.ChartObjects("Chart 58").Activate

With ActiveChart.SeriesCollection.NewSeries
.Values = ActiveSheet.Range("D" & btnIndex + 4 & ":O" &
btnIndex + 4)
.Name = "=""A" & btnIndex & """"
End With

ActiveChart.SeriesCollection("A" & Trim(Str(btnIndex))).Select
With Selection.Border
.ColorIndex = btnIndex
.Weight = xlThick
.LineStyle = xlContinuous
End With

With Selection
.MarkerBackgroundColorIndex = 2
.MarkerForegroundColorIndex = 3
.MarkerStyle = xlTriangle
.MarkerSize = 7
End With

' Tried variations on below...
ActiveChart.Legend.LegendEntries(btnIndex-1).LegendKey.Select
Selection.Delete

ActiveSheet.Buttons(Application.Caller).Text = "-"

Range(sitInCell).Select

' delete chart series on small button click
ElseIf ActiveSheet.Buttons(Application.Caller).Text = "-" Then
ActiveSheet.ChartObjects("Chart 58").Activate

ActiveChart.SeriesCollection("A" & Trim(Str(btnIndex))).Select
Selection.Delete

ActiveSheet.Buttons(Application.Caller).Text = "+"

Range(sitInCell).Select

End If

End Sub

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: chart legend names in a chart itself Jon Peltier Microsoft Excel Charting 0 22nd Jan 2007 11:11 PM
Re: chart legend names in a chart itself Tushar Mehta Microsoft Excel Charting 0 22nd Jan 2007 10:57 PM
Add series names to legend after the chart has been created =?Utf-8?B?QmFycnk=?= Microsoft Excel Charting 3 15th Jan 2007 08:48 AM
Hide series names for unused data from chart legend =?Utf-8?B?TmVpbCBHb2xkd2Fzc2Vy?= Microsoft Excel Charting 4 10th Feb 2006 07:13 PM
Chart Legend: Include more Data in my chart legend than what I have graphed eliese0 Microsoft Excel Charting 2 9th Aug 2004 11:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:35 PM.