ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Chart Name (https://www.excelbanter.com/excel-programming/363565-chart-name.html)

Zone

Chart Name
 
I have an embedded chart on a worksheet. Each time I run my macro, I
delete the existing chart and create it fresh. I would like for its
name to remain Chart 1, but Excel renames it each time it is created,
to something like "Sheet 1 Chart 22". I'm not sure this makes much
difference, but I am curious as to Excel's "memory" of the deleted
charts, and will I run into trouble when I get to chart names like
Sheet 1 Chart 280309387. (Excel 2002)
Thanks, James


Tom Ogilvy

Chart Name
 
activesheet.OleObjects(1).Chart.Name = "Chart 1"

--
Regards,
Tom Ogilvy


"Zone" wrote:

I have an embedded chart on a worksheet. Each time I run my macro, I
delete the existing chart and create it fresh. I would like for its
name to remain Chart 1, but Excel renames it each time it is created,
to something like "Sheet 1 Chart 22". I'm not sure this makes much
difference, but I am curious as to Excel's "memory" of the deleted
charts, and will I run into trouble when I get to chart names like
Sheet 1 Chart 280309387. (Excel 2002)
Thanks, James



Peter T

Chart Name
 
The sheet's 'object-counter' increments by one each time you insert any type
of object. The new default name is "object-type object-counter'.

AFAIK the only way to reset the counter is to delete all objects from the
sheet, save and close the file.

I've never had a problem even with the counter over a million, but not
tested to 280 million as it seems you intend to reach!

There might be a potential problem if creating new a object in VBA when the
counter reaches 65536 and in the same code .Select the object even if
there's only one object on the sheet (not sure why). But it's rarely
necessary to select anything in code.

Instead of deleting the chartobject each time why not update its chart.

Regards,
Peter T


"Zone" wrote in message
oups.com...
I have an embedded chart on a worksheet. Each time I run my macro, I
delete the existing chart and create it fresh. I would like for its
name to remain Chart 1, but Excel renames it each time it is created,
to something like "Sheet 1 Chart 22". I'm not sure this makes much
difference, but I am curious as to Excel's "memory" of the deleted
charts, and will I run into trouble when I get to chart names like
Sheet 1 Chart 280309387. (Excel 2002)
Thanks, James




Zone

Chart Name
 

Thanks, Tom and Peter.
James



All times are GMT +1. The time now is 10:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com