This code (see below) works pretty well automatically adding a linear trendline to a Pivot Chart, except when the user pivots on an item that has no records and therefore no graph, the program crashes. Is there any error traping code to prevent this? Thanks. WBS
Private Sub Chart_Calculate()
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(1).Trendlines.Add(Type:=xlLinear, Forward:=0, _
Backward:=0, DisplayEquation:=False, DisplayRSquared:=False).Select
ActiveChart.Deselect
End Sub
Private Sub Chart_Calculate()
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(1).Trendlines.Add(Type:=xlLinear, Forward:=0, _
Backward:=0, DisplayEquation:=False, DisplayRSquared:=False).Select
ActiveChart.Deselect
End Sub