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: 25
Default Chart Legend Names

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

 
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
Change Names of Legend Elaine Charts and Charting in Excel 5 August 17th 08 04:00 AM
Showing Series Names in Legend Andy Charts and Charting in Excel 1 March 23rd 07 02:59 PM
chart legend names in a chart itself Word-Dancer Charts and Charting in Excel 3 January 24th 07 11:49 AM
Add series names to legend after the chart has been created barry Charts and Charting in Excel 3 January 15th 07 08:48 AM
Hide series names for unused data from chart legend Neil Goldwasser Charts and Charting in Excel 4 February 10th 06 07:13 PM


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