View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.charting
 
Posts: n/a
Default Toggle Data Label "Value" On and Off

Found my own answer through recording macros. Here is the code I used,
applying it to a toggle button.

Private Sub ToggleButton1_Click()
Application.ScreenUpdating = False
If ToggleButton1.VALUE = True Then
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SeriesCollection(2).Select
ActiveChart.SeriesCollection(2).ApplyDataLabels AutoText:=True,
LegendKey:= _
False, ShowSeriesName:=False, ShowCategoryName:=False,
ShowValue:=True, _
ShowPercentage:=False, ShowBubbleSize:=False
ActiveChart.SeriesCollection(2).DataLabels.Select
Selection.AutoScaleFont = True
With Selection.Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 9
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 2
.Background = xlAutomatic
End With
Windows("GanttChartTemplatewc.xls").SmallScroll Down:=3
ActiveWindow.Visible = False
Windows("GanttChartTemplatewc.xls").Activate
Range("Q36").Select
ActiveWindow.SmallScroll Down:=-6
Else
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SeriesCollection(2).Select
ActiveChart.SeriesCollection(2).ApplyDataLabels AutoText:=True,
LegendKey:= _
False, ShowSeriesName:=False, ShowCategoryName:=False,
ShowValue:=False, _
ShowPercentage:=False, ShowBubbleSize:=False
Windows("GanttChartTemplatewc.xls").SmallScroll Down:=3
ActiveWindow.Visible = False
Windows("GanttChartTemplatewc.xls").Activate
Range("N36").Select
ActiveWindow.SmallScroll Down:=-6
Application.ScreenUpdating = True
End If
End Sub