Mega Code Archive

 
Categories / VisualBasic Script / Excel
 

Chart double click event

Private Sub Chart_BeforeDoubleClick(ByVal ElementID As Long, _                          ByVal Arg1 As Long, ByVal Arg2 As Long, Cancel As Boolean)          Dim seSeries As Series          Select Case ElementID          Case xlLegend              Me.HasLegend = False              Cancel = True          Case xlPlotArea              Me.HasLegend = True              Cancel = True          Case xlSeries              Set seSeries = Me.SeriesCollection(Arg1)              If Arg2 = -1 Then                  With seSeries.Border                     If .ColorIndex = xlColorIndexAutomatic Then                         .ColorIndex = 1                     Else                         .ColorIndex = (.ColorIndex Mod 56) + 1                     End If                  End With              Else                  With seSeries.Points(Arg2)                     .HasDataLabel = Not .HasDataLabel                  End With              End If              Cancel = True          End Select      End Sub