View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Losing Named Range Definitions

Hi Cliff,

When deleting items which are effectively in a collection, best to loop from
the last to the first. Why - say start with 3 items, delete two of them, now
cannot delete the 3rd item as now there's only one left (with loop from 1 to
3).

For x = ActiveSheet.ChartObjects.Count To 1 Step -1
ActiveSheet.ChartObjects(x).Delete
Next x

However to delete all chartobjects can do simply -
ActiveSheet.ChartObjects.Delete

Regards,
Peter T


"ward376" wrote in message
...
This will delete all the charts on a sheet:

Sub delChart()
Dim x As Integer
For x = 1 To ActiveSheet.ChartObjects.Count
ActiveSheet.ChartObjects(x).Delete
Next x
End Sub

Cliff Edwards