PC Review


Reply
Thread Tools Rate Thread

Charts(3).SetSourceData Not Working

 
 
Trip
Guest
Posts: n/a
 
      6th Jun 2007
Hi All,

I'm a bit confused here. If I run the command "msgbox
ActiveChart.Name" I get back "Sheet1 Chart 3".

Yet, if I run the command "Charts(3).SetSourceData..." I get a
"subscript out of range" error. This is true if I try 1, 2, 3, 4, 5,
and so on. However, if I run "ActiveChart.SetSourceData..." it works,
thus I know the issue is with the "Charts(3)" portion of the line.

What am I doing wrong?

Thanks!

Trip

 
Reply With Quote
 
 
 
 
Peter T
Guest
Posts: n/a
 
      6th Jun 2007
Hi Trip

The parent of a chart on a worksheet is a ChartObject

Dim chtObj as ChartObject
Dim cht as Chart

Set chtobj = ActiveSheet.Chartobjects("Chart 3")
Set cht = chtobj.Chart

msgbox chtobj.Name & vbcr & cht.Name

cht..SetSourceData...

BTW, if you did not "Activesheet.Charts(3)" but
Activesheet.Chartobjects(3).Chart,
you would pick up the 3rd Chartobject's chart on the sheet according to its
index order, which is not necessarily related to the '3' in its name.

Regards,
Peter T

"Trip" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi All,
>
> I'm a bit confused here. If I run the command "msgbox
> ActiveChart.Name" I get back "Sheet1 Chart 3".
>
> Yet, if I run the command "Charts(3).SetSourceData..." I get a
> "subscript out of range" error. This is true if I try 1, 2, 3, 4, 5,
> and so on. However, if I run "ActiveChart.SetSourceData..." it works,
> thus I know the issue is with the "Charts(3)" portion of the line.
>
> What am I doing wrong?
>
> Thanks!
>
> Trip
>



 
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
Help with SetSourceData EAB1977 Microsoft Excel Programming 1 12th Oct 2009 07:16 PM
I think the problem is in .SetSourceData ?? keith Microsoft Excel Programming 2 20th Apr 2009 12:53 PM
setSourcedata tony wong Microsoft Excel Programming 2 22nd Feb 2007 02:06 PM
SetSourceData Failure =?Utf-8?B?UGxlYXNlIEhlbHA=?= Microsoft Excel Programming 1 25th Jan 2005 05:09 AM
SetSourceData for Chart =?Utf-8?B?RG9lcnRl?= Microsoft Excel Programming 2 29th Nov 2004 11:55 AM


Features
 

Advertising
 

Newsgroups
 


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