+ Reply to Thread
Results 1 to 16 of 16

Using VBA to format Charts and Chart Objects

Hybrid View

  1. #1
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Using VBA to format Charts and Chart Objects

    using Jon's Peltier method found here
    http://peltiertech.com/apply-chart-f...-other-charts/

    where you select a "master" sheet then run to copy format from then apply to every other chart

    with the amendment he notes for excel version 2007+ fix
    It turns out that

    .Paste Type:=xlFormats
    does not work properly in Excel 2007 onwards. No error appears, but whatever Type is specified, the paste occurs as if you used xlPasteAll.

    The code that works is totally not obvious. Replace the above line with

    .Chart.ChartArea.Select
    ActiveSheet.PasteSpecial Format:=2
    I’d like to talk with the genius who decided PasteSpecial on the ActiveSheet should affect an embedded chart.
    Sub Copy_Chart_Formats()
    
        Dim Sht As Worksheet
        Dim Cht As ChartObject
        Dim Cht2 As Chart
        
        Application.ScreenUpdating = False
    
        ActiveChart.ChartArea.Copy
    
        For Each Sht In ActiveWorkbook.Worksheets 'look sheets in workbook
            For Each Cht In Sht.ChartObjects 'look charts in worksheet
                Cht.Chart.ChartArea.Select
                ActiveSheet.PasteSpecial Format:=2
            Next Cht
        Next Sht
    
        For Each Cht2 In ActiveWorkbook.Charts 'loop for each chart in activeworkbook
                Cht2.ChartArea.Select
                ActiveSheet.PasteSpecial Format:=2
        Next
        
        Application.ScreenUpdating = True
    
    End Sub
    i went with the simple one instead of the bigger one...you can endeavor to try the big version....Copy_Chart_Formats_Not_Titles
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  2. #2
    Registered User
    Join Date
    08-11-2014
    Location
    Washington
    MS-Off Ver
    version 13
    Posts
    14

    Re: Using VBA to format Charts and Chart Objects

    I tried Jon's vba and it worked but where I had 2 values, I got 4 and all the colors were different. The fonts were cloned, though.

    I went back and tried the subroutine "Copy_Chart_Formats". It errored on "ActiveSheet.PasteSpecial Format:=2" with the error "Object doesn't support this property or method".

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Copy charts from excel to PPT - unable to re size and format the chart
    By vickybansal99 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-24-2014, 12:37 PM
  2. Delink Charts and Objects
    By gdel in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-07-2014, 10:00 AM
  3. Hide or unhide charts or objects
    By Karak in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-26-2012, 09:23 AM
  4. [SOLVED] VBA to copy/paste chart format to all other charts in workbook
    By rarnett in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-14-2012, 09:12 AM
  5. Macro to delete all objects except charts
    By Mathematicus in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-24-2011, 03:12 PM
  6. insert excel charts as objects
    By mcarrington in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 01-07-2006, 01:00 AM
  7. [SOLVED] Draw Objects in Charts
    By Mike Hogan in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 10-06-2005, 09:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1