Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Objects error in ASP pages [email protected] Excel Programming 0 August 8th 05 11:05 AM
Cannot shift objects error beefycj5 Excel Discussion (Misc queries) 1 August 2nd 05 06:20 PM
Error: Can't Shift Objects off Sheet Bettergains Excel Discussion (Misc queries) 1 February 25th 05 11:55 PM
Error message with embedded objects. Robban Setting up and Configuration of Excel 0 December 15th 04 10:05 AM
Can not shift objects off sheet error Paul Robinson Excel Programming 0 September 25th 03 08:35 AM


All times are GMT +1. The time now is 08:53 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"