Try:
For Each Sht In ActiveWorkbook.Worksheets
Also try the amended code I posted to John's blog. Hmmm, looks like he
hasn't gotten my comment. Here's the code:
Sub Copy_Chart_Formats()
Dim Sht As Worksheet
Dim Cht As ChartObject
Application.ScreenUpdating = False
ActiveChart.ChartArea.Copy
For Each Sht In ActiveWorkbook.Worksheets
For Each Cht In Sht.ChartObjects
Cht.Chart.Paste Type:=xlFormats
Next Cht
Next Sht
Application.ScreenUpdating = True
End Sub
As I also mentioned in the comment that's gone AWOL, copying formats
from one chart and pasting them onto another also copies chart and axis
titles, so you may find yourself having to redo 230 sets of titles. You
would have to check for titles, save the text, and reapply them. (Data
labels and shapes are also not properly dealt with, but I'm not
including them in this routine.) The code is something like this:
Sub Copy_Chart_Formats_Not_Titles()
Dim Sht As Worksheet
Dim Cht As ChartObject
Dim chtMaster As Chart
Dim bTitle As Boolean
Dim bXTitle As Boolean
Dim bYTitle As Boolean
Dim sTitle As String
Dim sXTitle As String
Dim sYTitle As String
Application.ScreenUpdating = False
Set chtMaster = ActiveChart
For Each Sht In ActiveWorkbook.Worksheets
For Each Cht In Sht.ChartObjects
If Sht.Name = chtMaster.Parent.Parent.Name And _
Cht.Name = chtMaster.Parent.Name Then
' don't waste time on chtMaster
Else
With Cht.Chart
' get titles
bTitle = .HasTitle
If bTitle Then
sTitle = .ChartTitle.Characters.Text
End If
If .HasAxis(xlCategory) Then
bXTitle = .Axes(xlCategory).HasTitle
If bXTitle Then
sXTitle = .Axes(xlCategory).AxisTitle.Characters.Text
End If
End If
If .HasAxis(xlValue) Then
bYTitle = .Axes(xlValue).HasTitle
If bYTitle Then
sYTitle = .Axes(xlValue).AxisTitle.Characters.Text
End If
End If
' apply formats
chtMaster.ChartArea.Copy
.Paste Type:=xlFormats
' restore titles
If bTitle Then
.HasTitle = True
.ChartTitle.Characters.Text = sTitle
End If
If bXTitle Then
.Axes(xlCategory).HasTitle = True
.Axes(xlCategory).AxisTitle.Characters.Text = sXTitle
End If
If bYTitle Then
.Axes(xlValue).HasTitle = True
.Axes(xlValue).AxisTitle.Characters.Text = sYTitle
End If
End With
End If
Next Cht
Next Sht
Application.ScreenUpdating = True
End Sub
- Jon