+ Reply to Thread
Results 1 to 11 of 11

Thread: Formatting Multiple Charts

  1. #1
    Registered User
    Join Date
    04-26-2011
    Location
    New Orleans, LA
    MS-Off Ver
    Excel 2011
    Posts
    11

    Formatting Multiple Charts

    I have 12 separate databases built, each with 102 sheets and each sheet containing its own chart. I need to reformat 1) the font size on all the charts and 2) the y-axis title on all the charts. How can I do this?

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    2003 & 2007 & 2010
    Posts
    11,351

    Re: Formatting Multiple Charts

    Code is probably the simplest and quickest approach.

    Use the macro recorder whilst formatting the chart.
    The build some simple looping around this to process all charts.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    04-26-2011
    Location
    New Orleans, LA
    MS-Off Ver
    Excel 2011
    Posts
    11

    Re: Formatting Multiple Charts

    OK, I recorded the macro and tested it. It works fine, but would you mind walking me through the looping process?

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    2003 & 2007 & 2010
    Posts
    11,351

    Re: Formatting Multiple Charts

    Some along these lines for all the charts in the active workbook

    Sub X
    Dim chtTemp as chart
    
    for each chtTemp in activeworkbook.charts
         chttemp.activate
         ' your recorded code, which problably uses the Activechart object
         ' <your code>
    
    Next
    
    End Sub
    Cheers
    Andy
    www.andypope.info

  5. #5
    Registered User
    Join Date
    04-26-2011
    Location
    New Orleans, LA
    MS-Off Ver
    Excel 2011
    Posts
    11

    Re: Formatting Multiple Charts

    Thanks a lot. That worked great. I have another question, though. What would the macro be to change the chart title on all the charts?

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    2003 & 2007 & 2010
    Posts
    11,351

    Re: Formatting Multiple Charts

    Do the same thing, record a macro whilst doing the change and then add that to the code.

    If you still need help you need to provide more information, like how do you know what the title for a particular chart should be.
    Cheers
    Andy
    www.andypope.info

  7. #7
    Registered User
    Join Date
    04-26-2011
    Location
    New Orleans, LA
    MS-Off Ver
    Excel 2011
    Posts
    11

    Re: Formatting Multiple Charts

    I would like all of the charts to be title "1980 Democratic Primary"

  8. #8
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    2003 & 2007 & 2010
    Posts
    11,351

    Re: Formatting Multiple Charts

    So if you had used the recorder you would have got code similar to

    Activechart.HasTitle =True 
    Activechart.ChartTitle.Text = "1980 Democratic Primary"
    Cheers
    Andy
    www.andypope.info

  9. #9
    Registered User
    Join Date
    04-26-2011
    Location
    New Orleans, LA
    MS-Off Ver
    Excel 2011
    Posts
    11

    Re: Formatting Multiple Charts

    Thanks for all your help that worked great. Now, I have a new question. This is what I have. A database with 102 charts (each on their own sheet), one for each county in Illinois. Each sheet and chart are named for the county. I have a 14 database like this. I was asked to recreate these for all other states. Naming the sheets was the big problem. I was able to write a macro that renamed all the sheets equal to a range of cell values. SO, I was able to rename all my sheets with the new county names. However, the charts are still the old county names. Is there a way to rename all the charts with the titles pulled from a range of values like i did for the sheets?

  10. #10
    Registered User
    Join Date
    07-07-2011
    Location
    Australia
    MS-Off Ver
    excel2010
    Posts
    3

    Re: Formatting Multiple Charts

    Sub Macro1()
    'Format multiple charts
    Dim chtTemp As Chart
    For Each chtTemp In ActiveWorkbook.Charts
    chtTemp.Activate
    ActiveChart.ChartTitle.Select
    With Selection.Format.TextFrame2.TextRange.Font.Fill
    .Visible = msoTrue
    .ForeColor.RGB = RGB(255, 0, 0)
    .Transparency = 0
    .Solid
    End With
    Next
    End Sub

    Why will this not work. Stepping through the code it does not enter the loop. Using V2010.

  11. #11
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Apparently I can't say
    MS-Off Ver
    Apparently I can't say
    Posts
    8,274

    Re: Formatting Multiple Charts

    Hi, and welcome to the forum.

    Unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread.

    Please also note the forum rule about code tags.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.2.0