Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Changing Elements in Lots of Charts at One Time.

Changing Elements in Lots of Charts at One Time

Written by Allen Wyatt (last updated June 3, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


Chris has a workbook that contains a lot of small, identical charts. He wants to change some of the attributes of elements in each chart—such as color or font size—all at one time.

If you find yourself using a "non-default" chart often (which means changing the appearance of certain chart elements after the chart is created), then a great approach is to create a custom chart and save that format in Excel. You can then use the saved format to create all your new charts, thereby minimizing the amount of later formatting you need to do. How you save custom chart formats has been covered in other issues of ExcelTips.

Custom chart formats may be great for the future, but it doesn't help if you already have a whole bunch of charts in an existing workbook. In that case, the best solution is to use a macro which can step through all the charts in a workbook and make a desired change. You just need to decide up front which items you wish to change, and then program the macro to specifically change those items.

For example, the following macro changes the font color and size of the Y-axis labels. It loops through all the charts in the workbook, both sheets and embedded charts.

Sub ChangeAllCharts1()
    Dim cht As Chart
    Dim sht
    Dim ChtObj As ChartObject

    For Each cht In ActiveWorkbook.Charts
        With cht.Axes(xlValue).TickLabels.Font
            .Size = 20
            .Color = vbRed
        End With
    Next

    For Each sht In ActiveWorkbook.Sheets
        For Each ChtObj In sht.ChartObjects
            With ChtObj.Chart.Axes(xlValue).TickLabels.Font
                .Size = 20
                .Color = vbRed
            End With
        Next
    Next
End Sub

As written here, the macro changes the font size to 20 and the color to red. If you want the macro to change other elements, all you need to do is change the With statements to reflect the elements you want changed, or you could use a For...Next loop to step through all the chart elements. The following macro exhibits this technique, changing the background color of the charts in a workbook.

Sub ChangeAllCharts2()
    On Error Resume Next
    NewChartAreaColor = 34

    For J = 1 To ActiveWorkbook.Charts.Count
        ActiveWorkbook.Charts(J).Select

        'The pairs of line code indicate desired changes
        ActiveChart.ChartArea.Select
        Selection.Interior.ColorIndex = NewChartAreaColor
    Next J

    For J = 1 To ActiveWorkbook.Sheets.Count
        For K = 1 To Sheets(J).ChartObjects.Count
            Sheets(J).Select
            Sheets(J).ChartObjects(K).Activate

            'The pairs of line code indicate desired changes
            ActiveChart.ChartArea.Select
            Selection.Interior.ColorIndex = NewChartAreaColor
        Next K
    Next J
End Sub

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (7734) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. You can find a version of this tip for the older menu interface of Excel here: Changing Elements in Lots of Charts at One Time.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Printing a Short Selection

Need to print just a portion of a worksheet? It's easy to do if you follow the steps in this tip.

Discover More

Fixed-Width Settings when Converting Text to Columns

The Convert Text to Columns capabilities of Excel are very helpful when pulling apart information. When working with ...

Discover More

Copying Rows between Worksheets Based on a Text Value

Want to move data from one worksheet to another based on a text value in a column. There are a couple of ways you can ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (ribbon)

Labeling X-Y Scatter Plots

Figuring out how to get the data points in an X-Y scatter plot labeled can be confusing; Excel certainly doesn't make it ...

Discover More

Exporting Black and White Charts

Excel's charts are normally created in color, but you can print them in black and white. You may be looking for a way to ...

Discover More

How to Choose the Type of Chart to Use

Excel allows you to create all sorts of charts to visually display your data. With so many options available, how do you ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is four less than 7?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.