Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.charting
 
Posts: n/a
Default Toggle Data Label "Value" On and Off

Is there any way to toggle the "Value" label for a chart on and off
using a button linked to some VBA code. I'd like to be able to have
the label formatted (i.e. color, size, etc) so that the user just has
to click a button for the values to show on the bars of the chart.
Thanks for any help you can give!

-Josh

  #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

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



All times are GMT +1. The time now is 04:43 PM.

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"