PC Review


Reply
Thread Tools Rate Thread

Delete multiple chartobjects from one chart sheet

 
 
New Member
Join Date: Aug 2011
Posts: 1
 
      24th Aug 2011
The objective: Use VBA to delete multiple chartobjects from one chart sheet.

If multiple chartobjects are created on one chart using the following code:

Code:
Sub ChartCreate()
 
Dim chtTemp  As ChartObject
 
Charts.Add.Location Where:=xlLocationAsNewSheet, Name:="My Chart"
 
For j = 1 To 3
   Set chtTemp = Charts("My Chart").ChartObjects.Add(4 ^ j, 4 ^ j, 10, 10)
Next
 
Msgbox Charts("My Chart").ChartObjects.Count
 
End Sub 
The 3 chartobjects on the chart “My Chart” can be selected with the mouse and deleted by hitting the delete key. I can not duplicate this using VBA. I have tried the macro recorder, but it does not capture the delete command. I have tried using sendkeys, with no success. The VBA code that I have tried is below:

Code:
Sub ChartDelete()
 
For i = 1 To ActiveChart.ChartObjects.Count
   ActiveChart.ChartObjects(ActiveChart.ChartObjects(i).Name).Delete
Next
 
End Sub


If anyone knows of a work around it would be greatly appreciated. I have found this problem to be a challenge.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Position Chartobjects in Chart sheet ojv Microsoft Excel Programming 0 7th Dec 2009 04:12 PM
delete chartobjects! =?Utf-8?B?TWFnbnVz?= Microsoft Excel Programming 1 10th May 2005 01:01 PM
How to export all chartobjects in a sheet to powerpoint (creating a new ppt file) as pictures? Gunnar Johansson Microsoft Excel Charting 1 9th May 2005 05:10 AM
Protect chartobjects, allow copy paste but NOT CUT (or delete) Gunnar Johansson Microsoft Excel Programming 0 15th Sep 2004 09:26 PM
Multiple Charts within 1 Chart Sheet =?Utf-8?B?dGltZw==?= Microsoft Excel Charting 1 15th Jan 2004 03:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:07 AM.