How to deteremine the number of trendline in chart?

  • Thread starter Thread starter Danny
  • Start date Start date
D

Danny

Hi, I have a lot of charts (say ~110 charts) and would like to delete
all the trendline. However, the number of each chart may not be same.
Therefore, I need to determine the number of trendline by every chart.
Can commend to do it?
 
This procedure will remove all trendlines in all embedded charts and
chart sheets in the active workbook:


Sub KillTrendlines()
Dim sh As Object
Dim chtob As ChartObject
Dim cht As Chart
Dim srs As Series
Dim tr As Trendline

For Each sh In ActiveWorkbook.Sheets
For Each chtob In ws.ChartObjects
For Each srs In chtob.Chart.SeriesCollection
For Each tr In srs.Trendlines
tr.Delete
Next
Next
Next
Next

For Each cht In ActiveWorkbook.Charts
For Each srs In cht.SeriesCollection
For Each tr In srs.Trendlines
tr.Delete
Next
Next
Next

End Sub


- Jon
 
This procedure will remove all trendlines in all embedded charts and
chart sheets in the active workbook:

Sub KillTrendlines()
   Dim sh As Object
   Dim chtob As ChartObject
   Dim cht As Chart
   Dim srs As Series
   Dim tr As Trendline

   For Each sh In ActiveWorkbook.Sheets
     For Each chtob In ws.ChartObjects
       For Each srs In chtob.Chart.SeriesCollection
         For Each tr In srs.Trendlines
           tr.Delete
         Next
       Next
     Next
   Next

   For Each cht In ActiveWorkbook.Charts
     For Each srs In cht.SeriesCollection
       For Each tr In srs.Trendlines
         tr.Delete
       Next
     Next
   Next

End Sub

- Jon
-------
Jon Peltier
Peltier Technical Services, Inc.http://peltiertech.com/




- Show quoted text -

It works, Thanks.
 
Back
Top