View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
acw[_2_] acw[_2_] is offline
external usenet poster
 
Posts: 100
Default MACRO HELP NEEDED!

Hi

As the data is in the same location on each sheet, one way
would be to record a macro while you copy from sheet1 to
sheet 2 and make the changes to the data source. This
will give you the basis of your macro.

Edit the macro to remove the fixed reference to the new
chart name and replace it with something like

ActiveSheet.ChartObjects(1).Activate

When it comes to the source data, then replace the
original (something like)
ActiveChart.SetSourceData Source:=Sheets("sheet2").Range
("B1:H2"), PlotBy:= _
xlRows
with something like
ActiveChart.SetSourceData Source:=Sheets
(ActiveSheet.Name).Range("B1:H2"), PlotBy:= _
xlRows

You will have to build some form of loop to get through
all the sheets in the workbook (for i = 1 to
worksheets.count; sheets(i).select

This will have to be tempered to make sure that you don't
use the source sheet, or any sheet that you have already
done (if activesheet.name = "sheet1" then 'skip the
looping process).

Probably pay to copy the graphs to each of the sheets
first, then go back and grab each graph, then update the
data reference.

HTH

Tony

-----Original Message-----
does anyone have any suggestions for a macro to update

the source data for a chart when it is on a different
sheet? i have a couple charts that i have developed based
on data in sheet 1. i would like to replicate those
charts for data contained in sheet 2, then sheet 3, etc (i
have 60 sheets total). the data in sheet 2, sheet 3, etc.
is in the exact same location, but just referring to a
different project. i've started doing this manually and
it will be very time consuming.

is there some type of edit/replace feature that i could

use in a macro? or a box asking for the new source data
sheet (all the data locations remain the same)?

any assistance would be greatly appreciated.

.