View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jim Hagan Jim Hagan is offline
external usenet poster
 
Posts: 10
Default Chart "Name" Property

I have an application whereby I am automatically processing a bunch of data
and adding scatter plots (x-y plots) to a worksheet (not a chart sheet).

My spreadsheet currently has 3 charts on it. Using the following code ...

Private Sub DebugPrintChartNames()
Dim chtObj As ChartObject
For Each chtObj In ActiveSheet.ChartObjects
Debug.Print chtObj.Name
Next chtObj
End Sub

I see that my charts are named ...
Chart 1
Chart 2
Chart 3

Now if I delete 2 of the charts, (say charts 2 and 3 for example) and create
2 new charts, I see that my charts are now named as ...

Chart 1
Chart 4
Chart 5

First question is ... why doesn't Excel reuse the names Chart 2 and Chart
3, instead of creating Chart 4 and Chart 5?

Second question is ... is there a limit on how many charts can be created in
a worksheet?

Third issue ... I renamed the charts using the following code ...

Private Sub RenameChartObjects()
i = 1
For Each chtObj In ActiveSheet.ChartObjects
chtObj.Name = "Chart" & i
Debug.Print chtObj.Name
i = i + 1
Next chtObj
End Sub

.... and got the following chart names ...
Chart1
Chart2
Chart3

I then added an additional chart and again printed out the chart names, only
to get this ...

Chart1
Chart2
Chart3
Chart 6

If I delete all 4 charts and then add 1, the chart name is "Chart 7". Is
there a way to reinitialize the internal chart numbering within Excel?

My biggest concern is that I'll hit a limit on Excel's chart numbering
scheme somewhere down the line. I don't know what the line is or if I should
even be concerned. Nonetheless, I intend for the application to be used by a
number of people who can add or delete charts as they please. We're talking
about a relatively large amount of data with alot of dependent variables
within the data ( 200), so it's conceivable that 100 or more charts could be
created (until we can figure out what's important and what's not).

Thanks in advance for any help provided. Really just looking for an
explanation of how the chart numbering scheme works in Excel.

Jim Hagan