View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Jay Jay is offline
external usenet poster
 
Posts: 671
Default ChartObjects.Count is incorrect

That solved my chart naming issues, thanks!
--
Disregard, this is so I can find my post later.
***postedbyJay***


"Tom Ogilvy" wrote:

Avoid using the name:

Sub Tester1()
For Each ocht In ActiveSheet.ChartObjects
MsgBox ocht.Name & " - " & ocht.Chart.Name
Next

End Sub

but you can change the name manually. Make the drawing bar visible and
select the northwest arrow. Now click on the chart object and change the
name in the name bar. Reselect it and make sure it took. Turn on the macro
recorder while you do it and get the code to do it as well.

--
Regards,
Tom Ogilvy


--
regards,
Tom Ogilvy


"Jay" wrote:

Hello all,

I've run into a stupid issue, and I'm not sure how to get around it.

I'm trying to automatically change the data source of a chart. Basically
every month I need to move the data source ahead by a row (advance the chart
window by a month).

I'm trying to loop through the chart objects of the worksheet and I guess
there were numerous charts added then deleted. So my ChartObjects.Count
returns 13, but there are only 6 charts.

How can I either:
a) Reset the counter of ChartObjects?
b) Edit the chart names to be (for example) Chart 1 - Chart 6? Right now,
it's not consistent what charts were left. There's no continuous run of
values I can loop through.
c) Only look at valid charts? The chart has a name, so I can't screen out
using that variable. Maybe another is (consistently) missing from
non-viewable charts? I don't know.

Any ideas are appreciated.

Thanks,
Jay

--
Disregard, this is so I can find my post later.
***postedbyJay***