How to deteremine the number of trendline in chart?

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?
 
J

Jon Peltier

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
 
D

Danny

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top