A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Charts and Charting
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

duplicating charts in a workbook



 
 
Thread Tools Display Modes
  #1  
Old November 18th, 2003, 04:04 PM
Debra Dalgleish
external usenet poster
 
Posts: n/a
Default duplicating charts in a workbook

Turn on the macro recorder and record the steps as you create one chart.
Then, delete that chart and modify the code to loop through all the
sheets --

At the top of the code, add the following lines:

Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets

Just before the End Sub line, add:

Next ws

Also, change any reference from a specific sheet, to the variable 'ws'.
For example, instead of:

ActiveChart.SetSourceData _
Source:=Sheets("Sheet1").Range("A1:G6"), _
PlotBy:=xlRows
ActiveChart.Location Whe=xlLocationAsObject, _
Name:="Sheet1"

use:

ActiveChart.SetSourceData _
Source:=ws.Range("A1:G6"), _
PlotBy:=xlRows
ActiveChart.Location Whe=xlLocationAsObject, _
Name:=ws.Name

Run the revised macro, and it should create a chart on each sheet.


H wrote:
Hello,
I'd like to create the same chart (i.e., from the same range of data), on each worksheet in a workbook. Is there a quick way to do this? (like a batch chart function?)



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

  #2  
Old November 18th, 2003, 05:35 PM
Jon Peltier
external usenet poster
 
Posts: n/a
Default duplicating charts in a workbook

Another way, if the data is structured the same on all the sheets, is to
make a chart on one sheet, and format it the way it should appear
everywhere. Make as many copies of this sheet (with the chart on it) as
you need. Then one sheet at a time, copy the other data, and paste it
over the original values on the copied sheets.

Using recorded macros to create charts is okay, but they are not
efficient, and they require a fair bit of work to streamline. I use
them all the time, but I also use techniques like the one I describe above.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
http://www.geocities.com/jonpeltier/Excel/index.html
_______

Debra Dalgleish wrote:

Turn on the macro recorder and record the steps as you create one chart.
Then, delete that chart and modify the code to loop through all the
sheets --

At the top of the code, add the following lines:

Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets

Just before the End Sub line, add:

Next ws

Also, change any reference from a specific sheet, to the variable 'ws'.
For example, instead of:

ActiveChart.SetSourceData _
Source:=Sheets("Sheet1").Range("A1:G6"), _
PlotBy:=xlRows
ActiveChart.Location Whe=xlLocationAsObject, _
Name:="Sheet1"

use:

ActiveChart.SetSourceData _
Source:=ws.Range("A1:G6"), _
PlotBy:=xlRows
ActiveChart.Location Whe=xlLocationAsObject, _
Name:=ws.Name

Run the revised macro, and it should create a chart on each sheet.


H wrote:

Hello,
I'd like to create the same chart (i.e., from the same range of data),
on each worksheet in a workbook. Is there a quick way to do this?
(like a batch chart function?)





 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:46 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.