Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting Charts in Macros 1

Status
Not open for further replies.

bhujanga

Programmer
Oct 18, 2007
181
US
I'm trying to write a macro that will create charts from data that is imported from Access. Depending on the data it might create any number of charts. I have that part working just fine, but I can't figure out how to automatically clear out the old charts.

Part of the problem is that I don't see a way to control the naming of a new chart and so Excel automatically increments the chart number by one every time it creates a new chart even if the previous charts are no longer there. This prevents me from being able to create a loop that starts from Chart1 and goes through some safe number like Chart50 because eventually it will have gone higher then that. Is there a way to tell it to delete all of the charts on a certain worksheet or to control the naming when they are created?

Thanks.
 


This is an MS Access REPORTS forum.

Is you application, in EXCEL? Seems so. You might get better answers in forum707.

To delete charts on a sheet...
Code:
dim co as chartobject

for each co in activesheet.chartobjects
  co.delete
next
Please post your current code in forum707 to get answers for naming etc.


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Sorry about that, I was looking through the VBA forum but apparently when I logged in it threw me over to Access Reports without my noticing.
In any case you've answered my question, so thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top