Unlocking Charts

Written by Allen Wyatt (last updated November 13, 2021)
This tip applies to Excel 97, 2000, 2002, and 2003


A common task done in macros is to lock and unlock different cells and objects in a workbook. This is often done for protection reasons, so that things cannot be modified inadvertently by users. If you need to unlock the charts that are in your workbook, you can easily do so if you remember that even though charts can be considered drawing objects, you don't unlock them as drawing objects--you specifically unlock the chart object.

In addition, how you unlock a chart depends on whether it is a Chart sheet or a Chart object on a regular worksheet. The following code, named ChartUnProtect, provides an example of how to successfully unprotect both types of charts.

Sub ChartUnProtect()
    Dim wks As Worksheet
    Dim cht As Chart
    Dim chtObj As ChartObject
    Dim PW As String
    PW = "mypass"

    'Unprotect all Chart sheets
    For Each cht In ActiveWorkbook.Charts
        Sheets(cht.Name).Unprotect password:=PW
    Next

    'Unlock all Chart objects on each worksheet
    For Each wks In ActiveWorkbook.Worksheets
        wks.Unprotect password:=PW
        For Each chtObj In wks.ChartObjects
            wks.DrawingObjects(chtObj.Name).Locked = False
        Next
        wks.Protect password:=PW
    Next
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 (2264) applies to Microsoft Excel 97, 2000, 2002, and 2003.

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

Embedding Fonts in Excel

Unlike some other programs (like Word), Excel doesn't provide a way for you to embed fonts in a workbook. Here's a ...

Discover More

Vertical Alignment of an Inline Graphic

Word allows you to insert graphics in two ways: either inline or floating. If you use inline graphics, you may want to ...

Discover More

Creating Selections

Want a really easy way to create a selection of a group of cells? Discover how to use the Extend key to make this task ...

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

More ExcelTips (menu)

Unselecting a Chart Item

When formatting a chart, you select elements and then change the properties of those elements until everything looks just ...

Discover More

Positive and Negative Colors in a Chart

When creating a line cart, the line can show values both positive and negative values. This tip explains how you can use ...

Discover More

Changing Elements in Lots of Charts at One Time

Got a bunch of charts that you need to make formatting changes in? You can use a macro (or two) to apply the formatting ...

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 2 + 2?

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 menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon 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.