O'Reilly logo

Programming Excel with VBA and .NET by Steve Saunders, Jeff Webb

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Protect Items in a Workbook

Protecting prevents changes to parts of a workbook. You can apply protection to worksheets, charts, ranges, formatting, and window layout. Protection can use a password or it may omit the password if the protection is intended to prevent accidental changes rather than malicious ones.

You can protect multiple items within a workbook and you can use different passwords for each of those items, though that’s generally a bad idea. The more passwords you use, the more likely you are to confuse them—especially within a single workbook. It’s a good idea to use the same password when protecting multiple items.

To prevent changes to a worksheet:

  1. Add data to your worksheet and adjust the formatting so that it appears the way you want it to.

  2. From the Tools menu, choose Protection, then Protect a Sheet. Excel displays the Protect Sheet dialog box shown in Figure 26-7.

    Use protection to prevent changes

    Figure 26-7. Use protection to prevent changes

  3. Type a password and select the actions you want to permit on the worksheet from the list. Click OK. Excel prompts you to confirm the password.

After a worksheet is protected, you can’t change it without unprotecting it first. To unprotect the worksheet, select Tools → Protection → Unprotect Sheet and enter the password.

Worksheet protection applies to all of the locked cells on a worksheet. To allow users to edit some cells on a worksheet while protecting most ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required