Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Chart Objects Error
Hello,
I have two or more chart objects on worksheet that I want to delete before I rebuild them. I am using the following code to do that: Nchobj = ActiveSheet.ChartObjects.Count For i = 1 To Nchobj ActiveSheet.ChartObjects(i).Delete Next i Exit For The first one deletes OK. The second chart object generates this message: Unable to get ChartObjects property of the Worksheet class. On debug, it goes to the activesheet.chartobjects(i).delete line. Any ideas? Thanks. Bill |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Chart Objects Error
I'm not sure why you have that "exit for", but if you start at the highest
number and work down, it helps: Nchobj = ActiveSheet.ChartObjects.Count For i = Nchobj to 1 step -1 ActiveSheet.ChartObjects(i).Delete Next i Or if you just delete the first one (delete the first, the second becomes the new first, etc, etc, etc) Nchobj = ActiveSheet.ChartObjects.Count For i = 1 To Nchobj ActiveSheet.ChartObjects(1).Delete Next i Bill wrote: Hello, I have two or more chart objects on worksheet that I want to delete before I rebuild them. I am using the following code to do that: Nchobj = ActiveSheet.ChartObjects.Count For i = 1 To Nchobj ActiveSheet.ChartObjects(i).Delete Next i Exit For The first one deletes OK. The second chart object generates this message: Unable to get ChartObjects property of the Worksheet class. On debug, it goes to the activesheet.chartobjects(i).delete line. Any ideas? Thanks. Bill -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Chart Objects Error
Hi Bill,
The simplest way would have to be ActiveSheet.ChartObjects.Delete Regards, Vic Eldridge "Bill" wrote: Hello, I have two or more chart objects on worksheet that I want to delete before I rebuild them. I am using the following code to do that: Nchobj = ActiveSheet.ChartObjects.Count For i = 1 To Nchobj ActiveSheet.ChartObjects(i).Delete Next i Exit For The first one deletes OK. The second chart object generates this message: Unable to get ChartObjects property of the Worksheet class. On debug, it goes to the activesheet.chartobjects(i).delete line. Any ideas? Thanks. Bill |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel Objects error in ASP pages | Excel Programming | |||
Cannot shift objects error | Excel Discussion (Misc queries) | |||
Error: Can't Shift Objects off Sheet | Excel Discussion (Misc queries) | |||
Error message with embedded objects. | Setting up and Configuration of Excel | |||
Can not shift objects off sheet error | Excel Programming |