PC Review


Reply
Thread Tools Rate Thread

Change Multiple chart source data

 
 
Renate Stach
Guest
Posts: n/a
 
      21st Aug 2004
I have 200 charts (7 on each page)with one data page. I'd like to be
able to loop through the pages and charts and the row addresses. My
goal is to be able to change the column address from "f" to say "h"
for example, and have the macro loop through all the pages, charts
and range addresses.

I've figured out how to loop through activating the page and the
charts on each page, but can't figure out how to express the range
statement

.Range("A2:f6"),

with variables so I can loop through the row values for each chart.
I've tried statements like this -- but no luck. Am I just getting the
syntax wrong?

ActiveChart.SetSourceData Source:=Sheets("Sheet23").Range("A" &
"z" & ":" & "F" & "y"), _
PlotBy:=xlRows


I would like to loop rather than having 200 statement like this since
the column names are the same throughout and the row numbers increment
by 7.

ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.PlotArea.Select
ActiveChart.SetSourceData
Source:=Sheets("Sheet23").Range("A2:f6"), _
PlotBy:=xlRows

ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.PlotArea.Select
ActiveChart.SetSourceData
Source:=Sheets("Sheet23").Range("A9:f13"), _
PlotBy:=xlRows

ActiveSheet.ChartObjects("Chart 3").Activate
ActiveChart.ChartArea.Select
ActiveChart.SetSourceData
Source:=Sheets("Sheet23").Range("A16:f20"), _
PlotBy:=xlRows


Your help will be appreciated. Thank You.
Renate
 
Reply With Quote
 
 
 
 
Tom Ogilvy
Guest
Posts: n/a
 
      21st Aug 2004
Possibly you could loop through the seriescollection of each chart and do
something like:

ActiveChart.SeriesCollection(1).Formula = Application.Substitute( _
ActiveChart.SeriesCollection(1).Formula,"$F","$H")


The results of checking the formula property is

? ActiveChart.SeriesCollection(1).Formula
=SERIES('[aa_book1.xls]Sheet1'!$F$1,,'[aa_book1.xls]Sheet1'!$F$2:$F$14,1)

--
Regards,
Tom Ogilvy

"Renate Stach" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I have 200 charts (7 on each page)with one data page. I'd like to be
> able to loop through the pages and charts and the row addresses. My
> goal is to be able to change the column address from "f" to say "h"
> for example, and have the macro loop through all the pages, charts
> and range addresses.
>
> I've figured out how to loop through activating the page and the
> charts on each page, but can't figure out how to express the range
> statement
>
> .Range("A2:f6"),
>
> with variables so I can loop through the row values for each chart.
> I've tried statements like this -- but no luck. Am I just getting the
> syntax wrong?
>
> ActiveChart.SetSourceData Source:=Sheets("Sheet23").Range("A" &
> "z" & ":" & "F" & "y"), _
> PlotBy:=xlRows
>
>
> I would like to loop rather than having 200 statement like this since
> the column names are the same throughout and the row numbers increment
> by 7.
>
> ActiveSheet.ChartObjects("Chart 1").Activate
> ActiveChart.PlotArea.Select
> ActiveChart.SetSourceData
> Source:=Sheets("Sheet23").Range("A2:f6"), _
> PlotBy:=xlRows
>
> ActiveSheet.ChartObjects("Chart 2").Activate
> ActiveChart.PlotArea.Select
> ActiveChart.SetSourceData
> Source:=Sheets("Sheet23").Range("A9:f13"), _
> PlotBy:=xlRows
>
> ActiveSheet.ChartObjects("Chart 3").Activate
> ActiveChart.ChartArea.Select
> ActiveChart.SetSourceData
> Source:=Sheets("Sheet23").Range("A16:f20"), _
> PlotBy:=xlRows
>
>
> Your help will be appreciated. Thank You.
> Renate



 
Reply With Quote
 
Renate Stach
Guest
Posts: n/a
 
      23rd Aug 2004
Tom,

Thanks you so much!!!! This will save me tons of time.




"Tom Ogilvy" <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> Possibly you could loop through the seriescollection of each chart and do
> something like:
>
> ActiveChart.SeriesCollection(1).Formula = Application.Substitute( _
> ActiveChart.SeriesCollection(1).Formula,"$F","$H")
>
>
> The results of checking the formula property is
>
> ? ActiveChart.SeriesCollection(1).Formula
> =SERIES('[aa_book1.xls]Sheet1'!$F$1,,'[aa_book1.xls]Sheet1'!$F$2:$F$14,1)
>
> --
> Regards,
> Tom Ogilvy
>
> "Renate Stach" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > I have 200 charts (7 on each page)with one data page. I'd like to be
> > able to loop through the pages and charts and the row addresses. My
> > goal is to be able to change the column address from "f" to say "h"
> > for example, and have the macro loop through all the pages, charts
> > and range addresses.
> >
> > I've figured out how to loop through activating the page and the
> > charts on each page, but can't figure out how to express the range
> > statement
> >
> > .Range("A2:f6"),
> >
> > with variables so I can loop through the row values for each chart.
> > I've tried statements like this -- but no luck. Am I just getting the
> > syntax wrong?
> >
> > ActiveChart.SetSourceData Source:=Sheets("Sheet23").Range("A" &
> > "z" & ":" & "F" & "y"), _
> > PlotBy:=xlRows
> >
> >
> > I would like to loop rather than having 200 statement like this since
> > the column names are the same throughout and the row numbers increment
> > by 7.
> >
> > ActiveSheet.ChartObjects("Chart 1").Activate
> > ActiveChart.PlotArea.Select
> > ActiveChart.SetSourceData
> > Source:=Sheets("Sheet23").Range("A2:f6"), _
> > PlotBy:=xlRows
> >
> > ActiveSheet.ChartObjects("Chart 2").Activate
> > ActiveChart.PlotArea.Select
> > ActiveChart.SetSourceData
> > Source:=Sheets("Sheet23").Range("A9:f13"), _
> > PlotBy:=xlRows
> >
> > ActiveSheet.ChartObjects("Chart 3").Activate
> > ActiveChart.ChartArea.Select
> > ActiveChart.SetSourceData
> > Source:=Sheets("Sheet23").Range("A16:f20"), _
> > PlotBy:=xlRows
> >
> >
> > Your help will be appreciated. Thank You.
> > Renate

 
Reply With Quote
 
Jon Peltier
Guest
Posts: n/a
 
      24th Aug 2004
This is the mechanism behind the Change Series Formula macro I've posted
on my web site:

http://peltiertech.com/Excel/Charts/ChgSrsFmla.html

I have a few choices built into it: Active Chart vs. All Charts on
Sheet. Another For-Next loop around that will get all charts on all sheets.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______

Tom Ogilvy wrote:
> Possibly you could loop through the seriescollection of each chart and do
> something like:
>
> ActiveChart.SeriesCollection(1).Formula = Application.Substitute( _
> ActiveChart.SeriesCollection(1).Formula,"$F","$H")
>
>
> The results of checking the formula property is
>
> ? ActiveChart.SeriesCollection(1).Formula
> =SERIES('[aa_book1.xls]Sheet1'!$F$1,,'[aa_book1.xls]Sheet1'!$F$2:$F$14,1)
>


 
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
chart with data source from multiple worksheets אביאל Microsoft Excel Misc 2 7th Oct 2008 01:46 PM
Change Source Data in Chart Karen Microsoft Excel Charting 3 15th Aug 2008 09:30 PM
Change source data in a pivot chart =?Utf-8?B?am9obmI=?= Microsoft Excel Charting 4 12th Sep 2007 04:40 PM
change chart source from range to raw data daithimcc Microsoft Excel Programming 2 27th Dec 2003 05:19 PM
Adding multiple source data to chart Mark Microsoft Excel Charting 1 15th Nov 2003 12:23 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:44 PM.