PC Review


Reply
Thread Tools Rate Thread

ChartObjects.Count is incorrect

 
 
=?Utf-8?B?SmF5?=
Guest
Posts: n/a
 
      8th Aug 2007
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***
 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      8th Aug 2007
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***

 
Reply With Quote
 
Toyin.Butler@googlemail.com
Guest
Posts: n/a
 
      8th Aug 2007
Jay,

If you are changing the data source of a chart, it would be easier to
use a named range - the chart always looks at the named range, but the
named range changes.

Is the data a time series and are the columns you are switching
between in the same workbook? Or have I misinterpreted your underlying
issue?

Toy.

 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      8th Aug 2007
Hi Jay,

Maybe someone assumed that deleting rows or columns containing charts also
deletes the charts, rather than making them zero width or height and
effectively invisible.

Sub FindNonDeletedCharts()
Dim chtobj As ChartObject
For Each chtobj In ActiveSheet.ChartObjects
If chtobj.Width < 20 Then
chtobj.Width = 200
chtobj.Chart.ChartArea.Interior.ColorIndex = 3
End If
If chtobj.Height < 20 Then
chtobj.Height = 100
chtobj.Chart.ChartArea.Interior.ColorIndex = 3
End If
Next

Regards,
Peter T

"Jay" <(E-Mail Removed)> wrote in message
news:B06F46E7-5383-4F29-84C4-(E-Mail Removed)...
> 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***



 
Reply With Quote
 
=?Utf-8?B?SmF5?=
Guest
Posts: n/a
 
      8th Aug 2007
That solved my 'ghost' chart issues, thanks!
--
Disregard, this is so I can find my post later.
***postedbyJay***


"Peter T" wrote:

> Hi Jay,
>
> Maybe someone assumed that deleting rows or columns containing charts also
> deletes the charts, rather than making them zero width or height and
> effectively invisible.
>
> Sub FindNonDeletedCharts()
> Dim chtobj As ChartObject
> For Each chtobj In ActiveSheet.ChartObjects
> If chtobj.Width < 20 Then
> chtobj.Width = 200
> chtobj.Chart.ChartArea.Interior.ColorIndex = 3
> End If
> If chtobj.Height < 20 Then
> chtobj.Height = 100
> chtobj.Chart.ChartArea.Interior.ColorIndex = 3
> End If
> Next
>
> Regards,
> Peter T
>
> "Jay" <(E-Mail Removed)> wrote in message
> news:B06F46E7-5383-4F29-84C4-(E-Mail Removed)...
> > 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***

>
>
>

 
Reply With Quote
 
=?Utf-8?B?SmF5?=
Guest
Posts: n/a
 
      8th Aug 2007
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***

 
Reply With Quote
 
=?Utf-8?B?SmF5?=
Guest
Posts: n/a
 
      8th Aug 2007
Toy,

I hadn't thought of using a named range.

I've run into all sorts of issues trying to change the XValues and Values of
a SeriesCollection. I can set the value, but I can't retrieve the value.

I'm going to try the named range route. I can't find a way to retrieve the
XValues/Values for me to parse and increment.

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


"(E-Mail Removed)" wrote:

> Jay,
>
> If you are changing the data source of a chart, it would be easier to
> use a named range - the chart always looks at the named range, but the
> named range changes.
>
> Is the data a time series and are the columns you are switching
> between in the same workbook? Or have I misinterpreted your underlying
> issue?
>
> Toy.
>
>

 
Reply With Quote
 
Toyin.Butler@googlemail.com
Guest
Posts: n/a
 
      8th Aug 2007
One thing to note when using named ranges for chart series, ensure you
name your range for the worksheet only and not the workbook.

i.e. Sheet1!NamedRange

Then when refering to the name range you will need to put Sheet1!
NamedRange in the chart series.

Regards,

Toyin.

ps - I hope you can find your post later!

 
Reply With Quote
 
=?Utf-8?B?SmF5?=
Guest
Posts: n/a
 
      8th Aug 2007
I found a small problem with this named range solution.

I have 30+ charts I need to create named ranges for. With 3+ series in each
chart.

I think I might be farther ahead if I can find a way to modify the XValues
and Values instead. That way it won't be dependant on the named ranges, and
then I won't have to create them all.

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


"(E-Mail Removed)" wrote:

> One thing to note when using named ranges for chart series, ensure you
> name your range for the worksheet only and not the workbook.
>
> i.e. Sheet1!NamedRange
>
> Then when refering to the name range you will need to put Sheet1!
> NamedRange in the chart series.
>
> Regards,
>
> Toyin.
>
> ps - I hope you can find your post later!
>
>

 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      8th Aug 2007
http://j-walk.com/ss/excel/tips/tip83.htm

that should help with the xValues, etc

--
Regards,
Tom Ogilvy


"Jay" wrote:

> I found a small problem with this named range solution.
>
> I have 30+ charts I need to create named ranges for. With 3+ series in each
> chart.
>
> I think I might be farther ahead if I can find a way to modify the XValues
> and Values instead. That way it won't be dependant on the named ranges, and
> then I won't have to create them all.
>
> Any ideas?
> --
> Disregard, this is so I can find my post later.
> ***postedbyJay***
>
>
> "(E-Mail Removed)" wrote:
>
> > One thing to note when using named ranges for chart series, ensure you
> > name your range for the worksheet only and not the workbook.
> >
> > i.e. Sheet1!NamedRange
> >
> > Then when refering to the name range you will need to put Sheet1!
> > NamedRange in the chart series.
> >
> > Regards,
> >
> > Toyin.
> >
> > ps - I hope you can find your post later!
> >
> >

 
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
Query gives incorrect count of records =?Utf-8?B?QnJ1Y2U=?= Microsoft Access Queries 4 26th Aug 2006 10:54 PM
Incorrect Record Count in Union =?Utf-8?B?UGV0ZQ==?= Microsoft Access Queries 6 22nd Feb 2006 10:48 PM
Incorrect unread count Laura Microsoft Outlook 0 10th Sep 2004 10:13 PM
Unread message count incorrect Mary Microsoft Outlook Discussion 1 8th Apr 2004 07:16 PM
COUNT() returns incorrect value Bill Mathews Microsoft Excel Worksheet Functions 1 16th Aug 2003 02:58 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:02 AM.