cellMatrix.net

Spreadsheet Modeling and Related Topics

VBA to Copy Embedded Chart Formatting

A recent post to the Microsoft Excel Charting Discussion group asked "how do I copy the formatting for one embedded chart to another 230 charts in a workbook?" I responded with the following . . . select the embedded chart that you consider your formatted source or template. Next, run the following macro:

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

Although the macro works I don't think it's written well because it individually activates each sheet and embedded chart to copy the formats. How could this macro be improved?

UPDATE

Upon testing this procedure, Jon Peltier noted that it failed to copy title formatting. Jon's recent post titled Apply Chart Formatting to Other Charts rewrites the procedure to copy all chart formatting.


Posted on Monday, August 17, 2009 | Comments (0) | Permalink

Comment Entry Form

User Information

Name: (Required)

E-Mail Address: (Optional)

Location: (Optional)

Web Site Address: (Optional)

Comment Formatting Reference
Add VBA Code:
<pre>some code here</pre>
Linking:
[url]http://www.example.com/[/url]
[url=http://www.example.com/]my site[/url]
Text Formatting
[size=4]Some larger text[/size]
[color=green]Some green text[/color]
[b]Some bold text[/b]
[i]Some italic text[/i]
Enter Comment Below

Personalization Options
Remember my personal information
Notify me of follow-up comments?

Next entry: A Dicey Line Graph

Previous entry: Update on Browser Compatability

<< Back to main

Statistics

  • Total Entries - 134
  • Current Viewers - 13

Categories

Entries by Day

Mar - 2010
S M T W T F S
28 1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31 1 2 3

Recent Comments

Syndicate