View Single Post
  #4  
Old August 18th, 2009, 12:34 PM posted to microsoft.public.excel.charting
John Mansfield
external usenet poster
 
Posts: 218
Default Applying template settings over multiple charts

Ian, I'm not able to replicate but try this:

After this statement: Application.ScreenUpdating = False

Add this statement: On Error Resume Next

It will allow the code to run even if it's picking up an error.

--
John Mansfield
http://www.cellmatrix.net


"Ian" wrote:

I pasted the code in the VB editor and when I went to run the macro in Excel,
it says "Run-time error '13' Type mismatch" When I go to debug, the line of
code "For Each Sht In ActiveWorkbook.Sheets" is highlighted in yellow.

I don't know much about VB; the only code I kind of know is C++ so I
wouldn't know how to fix it. What should I do? Thanks for helping me.

"John Mansfield" wrote:

Assuming all of the charts are embedded charts, you could give a macro like
the one below a try. Copy the procedure into a standard module. Next,
select / activate (click on the outer container) the chart that you consider
your template. Go to Tools - Macro - Macros and run it.

Sub Copy_Chart_Formats()

Dim Sht As Worksheet
Dim Cht As ChartObject

Application.ScreenUpdating = False

ActiveChart.ChartArea.Copy

For Each Sht In ActiveWorkbook.Sheets
Sht.Activate
For Each Cht In ActiveSheet.ChartObjects
Cht.Activate
ActiveChart.Paste Type:=xlFormats
Next Cht
Next Sht

End Sub

As a side note, I don't think it's well written because it activates each
sheet and chart to copy the formats. However, I can't seem to get it to work
any other way without spending more time to experiment.

--
John Mansfield
http://www.cellmatrix.net


"Ian" wrote:

Hi, I have over 230 charts in my workbook. I've modified a template to use
for them. How do I apply it over every single chart instantly without having
to go through each chart and doing it manually? Thanks for any help.