Protect one sheet in excel

To prevent other users from accidentally or deliberately changing, moving, or deleting data in a worksheet, you can lock the cells on your Excel worksheet and then protect the sheet with a password. Say you own the team status report worksheet, where you want team members to add data in specific cells only and not be able to modify anything else. With worksheet protection, you can make only certain parts of the sheet editable and users will not be able to modify data in any other region in the sheet. 

Important: Worksheet level protection is not intended as a security feature. It simply prevents users from modifying locked cells within the worksheet. Protecting a worksheet is not the same as protecting an Excel file or a workbook with a password. See below for more information:

  • To lock your file so that other users can’t open it, see Protect an Excel file.

  • To prevent users from adding, modifying, moving, copying, or hiding/unhiding sheets within a workbook, see Protect a workbook.

  • To know the difference between protecting your Excel file, workbook, or a worksheet see Protection and security in Excel.

The following sections describe how to protect and unprotect a worksheet in Excel for Windows.

Here’s what you can lock in an unprotected sheet:

  • Formulas: If you don’t want other users to see your formulas, you can hide them from being seen in cells or the Formula bar. For more information, see Display or hide formulas.

  • Ranges: You can enable users to work in specific ranges within a protected sheet. For more information, see Lock or unlock specific areas of a protected worksheet.

Note: ActiveX controls, form controls, shapes, charts, SmartArt, Sparklines, Slicers, Timelines, to name a few, are already locked when you add them to a spreadsheet. But the lock will work only when you enable sheet protection. See the subsequent section for more information on how to enable sheet protection.

Worksheet protection is a two-step process: the first step is to unlock cells that others can edit, and then you can protect the worksheet with or without a password.

Step 1: Unlock any cells that needs to be editable

  1. In your Excel file, select the worksheet tab that you want to protect.

  2. Select the cells that others can edit.

    Tip: You can select multiple, non-contiguous cells by pressing Ctrl+Left-Click.

  3. Right-click anywhere in the sheet and select Format Cells (or use Ctrl+1, or Command+1 on the Mac), and then go to the Protection tab and clear Locked.

    Protection tab in the Format Cells dialog box

Step 2: Protect the worksheet

Next, select the actions that users should be allowed to take on the sheet, such as insert or delete columns or rows, edit objects, sort, or use AutoFilter, to name a few. Additionally, you can also specify a password to lock your worksheet. A password prevents other people from removing the worksheet protection—it needs to be entered to unprotect the sheet.

Given below are the steps to protect your sheet.

  1. On the Review tab, click Protect Sheet.

    The Changes group on the Review tab

  2. In the Allow all users of this worksheet to list, select the elements you want people to be able to change.

    The Protect Sheet dialog box

    Option

    Allows users to

    Select locked cells

    Move the pointer to cells for which the Locked box is checked on the Protection tab of the Format Cells dialog box. By default, users are allowed to select locked cells.

    Select unlocked cells

    Move the pointer to cells for which the Locked box is unchecked on the Protection tab of the Format Cells dialog box. By default, users can select unlocked cells, and they can press the TAB key to move between the unlocked cells on a protected worksheet.

    Format cells

    Change any of the options in the Format Cells or Conditional Formatting dialog boxes. If you applied conditional formatting before you protected the worksheet, the formatting continues to change when a user enters a value that satisfies a different condition.

    Format columns

    Use any of the column formatting commands, including changing column width or hiding columns (Home tab, Cells group, Format button).

    Format rows

    Use any of the row formatting commands, including changing row height or hiding rows (Home tab, Cells group, Format button).

    Insert columns

    Insert columns.

    Insert rows

    Insert rows.

    Insert hyperlinks

    Insert new hyperlinks, even in unlocked cells.

    Delete columns

    Delete columns.

    Note: If Delete columns is protected and Insert columns is not protected, a user can insert columns but cannot delete them.

    Delete rows

    Delete rows.

    Note: If Delete rows is protected and Insert rows is not protected, a user can insert rows but cannot delete them.

    Sort

    Use any commands to sort data (Data tab, Sort & Filter group).

    Note: Users can’t sort ranges that contain locked cells on a protected worksheet, regardless of this setting.

    Use AutoFilter

    Use the drop-down arrows to change the filter on ranges when AutoFilters are applied.

    Note: Users cannot apply or remove AutoFilter on a protected worksheet, regardless of this setting.

    Use PivotTable reports

    Format, change the layout, refresh, or otherwise modify PivotTable reports, or create new reports.

    Edit objects

    Doing any of the following:

    • Make changes to graphic objects including maps, embedded charts, shapes, text boxes, and controls that you did not unlock before you protected the worksheet. For example, if a worksheet has a button that runs a macro, you can click the button to run the macro, but you cannot delete the button.

    • Make any changes, such as formatting, to an embedded chart. The chart continues to be updated when you change its source data.

    • Add or edit notes.

    Edit scenarios

    View scenarios that you have hidden, making changes to scenarios that you have prevented changes to, and deleting these scenarios. Users can change the values in the changing cells, if the cells are not protected, and add new scenarios.

  3. Optionally, enter a password in the Password to unprotect sheet box and click OK. Reenter the password in the Confirm Password dialog box and click OK.

    Important: 

    • Use strong passwords that combine uppercase and lowercase letters, numbers, and symbols. Weak passwords don’t mix these elements. Passwords should be 8 or more characters in length. A passphrase that uses 14 or more characters is better.

    • It is critical that you remember your password. If you forget your password, Microsoft cannot retrieve it.

The Protect Sheet option on the ribbon changes to Unprotect Sheet when a sheet is protected. To view this option, click the Review tab on the ribbon, and in Changes, see Unprotect Sheet.

The Changes group on the Review tab

The Changes group on the Review tab

To unprotect a sheet, follow these steps:

  1. Go to the worksheet you want to unprotect.

  2. Go to File > Info > Protect > Unprotect Sheet, or from the Review tab > Changes > Unprotect Sheet.

  3. If the sheet is protected with a password, then enter the password in the Unprotect Sheet dialog box and click OK.

The following sections describe how to protect and unprotect a worksheet in Excel for the Web.

  1. Select Review Manage Protection.

  2. To turn on protection, in the Manage Protection task pane, select Protect sheet.

    Note      Although you can selectively protect parts of the sheet by setting various options in the Options section, these settings only apply when the Protect sheet setting is on.

    Managing sheet protection

  3. By default, the entire sheet is locked and protected.  To unlock specific ranges, select Unlocked ranges, and then enter a range name and cell range. You can add more than one range.

    Setting range protection

  4. Optionally, to require a password to edit a range, select Range password, enter and confirm the password, and then select Save. Make sure sheet protection is turned on.

    Setting range protection

  5. Optionally, to control the ability to edit protections for the entire sheet with a password, select Sheet protection password, enter and confirm the password, and then select Save.

    Setting a sheet password
    Important

    • Use strong passwords that combine uppercase and lowercase letters, numbers, and symbols. Weak passwords don’t mix these elements. Passwords should be 8 or more characters in length. Make sure the CAPS LOCK key is off and use correct capitalization. Passwords are case-sensitive.

    • It is critical that you remember your password. If you forget your password, Microsoft cannot retrieve it.

  6. Optionally, if you want to selectively enable and disable specific sheet elements, select the Options section, and then select one or more options.

    Option

    Allows users to

    Select locked cells

    Move the pointer to cells for which the Locked box is checked on the Protection tab of the Format Cells dialog box. By default, users are allowed to select locked cells.

    Select unlocked cells

    Move the pointer to cells for which the Locked box is unchecked on the Protection tab of the Format Cells dialog box. By default, users can select unlocked cells, and they can press the TAB key to move between the unlocked cells on a protected worksheet.

    Format cells

    Change any of the options in the Font and Alignment groups of the Home tab.

    Note      If cell formatting and hidden properties were previously protected by using the Format Cells or Conditional Formatting dialog boxes, they remain protected, but you can only modify options in these dialog boxes by using Excel for Windows. If you applied conditional formatting before you protected the worksheet, the formatting continues to change when a user enters a value that satisfies a different condition.

    Format columns

    Use any of the column formatting commands, including changing column width or hiding columns (Home tab, Cells group, Format button).

    Format rows

    Use any of the row formatting commands, including changing row height or hiding rows (Home tab, Cells group, Format button).

    Insert columns

    Insert columns.

    Insert rows

    Insert rows.

    Insert hyperlinks

    Insert new hyperlinks, even in unlocked cells.

    Delete columns

    Delete columns.

    Note: If Delete columns is protected and Insert columns is not protected, a user can insert columns but cannot delete them.

    Delete rows

    Delete rows.

    Note: If Delete rows is protected and Insert rows is not protected, a user can insert rows but cannot delete them.

    Sort

    Use any commands to sort data (Data tab, Sort & Filter group).

    Note: Users can’t sort ranges that contain locked cells on a protected worksheet, regardless of this setting.

    Use AutoFilter

    Use the drop-down arrows to change the filter on ranges when AutoFilters are applied.

    Note: Users cannot apply or remove AutoFilter on a protected worksheet, regardless of this setting.

    Use PivotTable reports

    Format, change the layout, refresh, or otherwise modify PivotTable reports, or create new reports.

    Edit objects

    Doing any of the following:

    • Make changes to graphic objects including maps, embedded charts, shapes, text boxes, and controls that you did not unlock before you protected the worksheet. For example, if a worksheet has a button that runs a macro, you can click the button to run the macro, but you cannot delete the button.

    • Make any changes, such as formatting, to an embedded chart. The chart continues to be updated when you change its source data.

    • Add or edit notes.

    Edit scenarios

    View scenarios that you have hidden, making changes to scenarios that you have prevented changes to, and deleting these scenarios. Users can change the values in the changing cells, if the cells are not protected, and add new scenarios.

    Notes

    • If you don’t want other users to see your formulas, you can hide them from being seen in cells or the Formula bar. For more information, see Display or hide formulas.

    • ActiveX controls, form controls, shapes, charts, SmartArt, Sparklines, Slicers, Timelines, and so on, are already locked when you add them to a spreadsheet. But the lock works only when you enable sheet protection. For more information, see Protect controls and linked cells on a worksheet.

There are two ways to unprotect a sheet, disable it or pause it.

Disable protection

  1. Select Review Manage Protection.

  2. To turn off protection, In the Manage Protection task pane, turn off Protect sheet.

    Turning sheet protection off

Pause protection

Pausing protection turns off protection for the current editing session while maintaining the protection for other users in the workbook. For example, you can pause protection to edit a locked range but maintain protection for other users.

  1. To pause sheet protection, select Review Pause Protection.

    Pausing sheet protection

    Note      If the sheet has a protection password, you must enter that password to pause protection.

  2. To resume sheet protection, select Review Resume Protection.

    Resuming sheet protection

At the bottom of the sheet, the sheet tab displays a locked icon if the sheet is protected (Sheet1), and an unlocked icon if it is paused (Sheet2).

Revealing sheet protection

See Also

Protection and security in Excel

Protect an Excel file

Protect a workbook

Lock or unlock specific areas of a protected worksheet

Lock cells to protect them

Display or hide formulas

Protect controls and linked cells on a worksheet

Copy and paste in a protected worksheet

Video: Password protect workbooks and worksheets (Excel 2013)

Protecting Excel Sheet

Protect worksheet is a feature in Excel when we do not want any other user to make changes to our worksheet. It is available in the “Review” tab of Excel. It has various features where we can allow users to perform some tasks but not make changes, such as they can select cells to use an AutoFilter but cannot make any changes to the structure. Also, it is recommended to protect a worksheet with a password.

An Excel worksheet that is protected using a password and/or has the cells in the worksheet locked to prevent any changes is known as a “Protect Sheet.”

Purpose of a Protecting sheet with a password

To prevent the unknown users from accidentally or purposely changing, editing, moving, or deleting data in a worksheet, you can lock the cells in the Excel worksheet and then protect an Excel sheet with a password.

Table of contents
  • Protecting Excel Sheet
    • #1 How to Protect a Sheet in Excel?
    • #2 How to Protect Cells in an Excel Worksheet?
    • #3 How to Hide the Formula Associated with a Cell?
    • Pros
    • Cons
    • Things to Remember
    • Recommended Articles

#1 How to Protect a Sheet in Excel?

Below are the steps for protecting the sheet in Excel:

  1. First, open the worksheet you wish to save. Then, right-click the worksheet or go to “Review” and “Protect Sheet.” The option lies in the “Changes” group, then click on “Protect Sheet” from the list of options displayed.

    Protect sheet Example 1

  2. It will prompt you to enter a password.

    Protect sheet Example 1-1

  3. Insert the password as per choice.

    Protect sheet Example 1-2

  4. The section below displays a list of options you can allow the users of the worksheet to perform. Every action has a checkbox. Check those actions you wish to enable the worksheet users to complete.

    Protect sheet Example 1-3

  5. If no action is checked, the users may only VIEW the file and not perform any updates by default. Click on “OK.”

    Protect sheet Example 1-4

  6. Re-enter the password as prompted on the second screen. Then, click on “OK.”

    Protect sheet Example 1-5

#2 How to Protect Cells in an Excel Worksheet?

To protect cells in Excel, follow the steps given below:

  • Step 1: Right, click on the Excel cell you wish to protect. Then, select “Format Cells” from the menu displayed.

Protect sheet Example 2

  • Step 2: Go to the tab named “Protection.”

Protect sheet Example 2-1

  • Step 3: Check “Locked” if you wish to lock the cell in Excel. It will prevent the cell from editing, and we can only view the content. Check “Hidden” if you wish to hide the cell. It will hide the cell and so the content.

Protect sheet Example 2-2

#3 How to Hide the Formula Associated with a Cell?

  • Step 1: As shown below, cell F2 has a formula: D2+E2 = F2.

Example 3

  • Step 2: Below shows that the Excel cell is protected as “Locked” and “Hidden” as both the options are checked.

sheet Example 3-1

  • Step 3: As a result, the formula is hidden / not visible in the formula bar, as shown below.

Example 3-2

  • Step 4: Upon unprotecting the sheet, the formula also starts appearing in the formula bar, as shown below.

Example 3-3

Pros

  1. A protected Excel sheet with a password is used to secure sensitive information from unwanted changes done by unauthorized entities.
  2. Excel worksheet cell actions are access controlled. It means they can be configured to be available for some users and not others.

Cons

  • If you protect an Excel sheet with a password, and if it is forgotten, it is non-recoverable. It means there is no automated or manual way of resetting or recovering the old password. It can cause data loss.

Things to Remember

  1. The password of the protected sheet is case-sensitive.
  2. The password of the protected sheet is non-recoverable.
  3.  If no actions are checked in the “Protect Sheet” dialog window, the default accessibility is “View.” It means the others can view the protected worksheet and cannot add new data or make any changes to the cells in the worksheet.
  4. Protecting the sheet is mandatory if one wishes to protect the cells as locked or hidden.
  5. If the sheet is unprotected in ExcelOnce the workbook has been password-protected, one must input the exact password that was entered while protecting the workbook in order to unprotect it.read more, all the formatting/locking associated with the cells would be overridden/gone.
  6. Locking a cell in Excel prevents it from making any changes.
  7. Hiding a cell hides the formula associated with it, making it invisible in the formula bar.

Recommended Articles

This article is a guide to Protect Sheet in Excel. We discuss how to protect sheets in Excel, practical examples, and downloadable Excel templates. You may learn more about Excel from the following articles: –

  • VBA UnProtect Sheet
  • Vba Protect SheetVBA Protect Sheet is an In-built function that protects the worksheet with a password & prohibits the users from editing, deleting, or moving the contained data. read more
  • Scroll Lock in ExcelWhen we press the down arrow key from any cell, it normally moves us to the next cell below it, but when we have scroll lock turned on, it drags the worksheet down while the cursor stays in the same cell.read more
  • Lock Cells in ExcelIn Excel, cells are locked to protect them from unwanted editing, deleting, and overwriting. Locking cells is specifically beneficial in cases where an excel worksheet needs to be shared with several colleagues.read more
  • Split Panes in ExcelSplitting panes in excel means splitting a workbook in different parts, this technique is available in the windows section of the View tab, panes can be split in horizontal or vertical way or it can be a cross split, the horizontal and vertical split can be seen in the mid-section of the worksheet however cross split can be done by dragging the panes.read more

Reader Interactions

When it comes time to send your Excel spreadsheet, it’s important to protect the data that you’re sharing. You might want to share your data, but that doesn’t mean it should be changed by someone else.

Spreadsheets often contain essential data that shouldn’t be modified or removed by the recipient. Luckily, Excel has built-in features to protect your spreadsheets.

In this tutorial, I’ll help you make sure that your Excel workbooks maintain data integrity. Here are three key techniques you’ll learn in this tutorial:

  • Password protect entire workbooks to prevent them from being opened by unauthorized users.
  • Protect individual sheets and the workbook structureto prevent the insertion or deletion of sheets in the workbook.
  • Protect cells, to specifically allow or disallow changes to key cells or formulas in your Excel spreadsheets.

Even users with the best intentions may accidentally break an important or complex formula. The best thing to do is remove the option to change your spreadsheets altogether.

How to Protect Excel: Cells, Sheets, & Workbooks (Watch & Learn)

In the screencast below, you’ll see me work through several important types of protection in Excel. We’ll protect an entire workbook, a single spreadsheet, and more.

Want a step-by-step walkthrough? Check out my steps below to find out how to use these techniques. You’ll learn how to protect your workbook in Excel, as well as protecting individual worksheets, cells, and how to work with advanced settings. 

We start with broader worksheet protections, then work down to narrower targeted protections you can apply in Excel. Let’s get started learning how to protect your spreadsheet data:

1. Password Protect an Excel Workbook File

Let’s start off by protecting an entire Excel file (or workbook) with a password to prevent others from opening it.

This is a breeze to do. While working in Excel, navigate to the File tab choose the Info tab. Click on the Protect Workbook dropdown option and choose Encrypt with Password.

As is the case with any password, choose a strong and secure combination of letters, numbers, and characters, bearing in mind that passwords are case-sensitive.

Encrypt with PasswordEncrypt with PasswordEncrypt with Password

Browse to the File > Info tab, and choose Protect Workbook > Encrypt with password.

It’s important to note that Microsoft has really beefed up the seriousness of their password protection in Excel. In prior versions, there were easy workarounds to bypass password protection of Excel workbooks, but not in newer versions.

Encrypt documentEncrypt documentEncrypt document

Set a complex password for security’s sake, but make sure to store it safely.

In Excel 2013 and beyond, the password implementation will prevent these traditional methods to bypass it. Make sure that you store your passwords carefully and safely or you risk permanently losing access to your crucial workbooks.

Excel Workbook — Mark as Final

If you want to be a bit less forceful with your spreadsheets, consider using the Mark as Final feature. When you mark an Excel file as the final version, it switches the file to read-only mode, and the user will have to re-enable editing.

To change a file to read-only mode, return to the File > Info button, and click on Protect Workbook again. Click on Mark as Final and confirm that you want to mark the document as a final version.

Mark as final protect Excel workbookMark as final protect Excel workbookMark as final protect Excel workbook

Mark a file as the final version to leave a gentle warning for users of that file. 

Marking a file as the final version will add a soft warning to the top of the file. Anyone who opens the file after it has been marked as final will see a notice, warning them that the file is finalized. 

Excel Workbook Marked as FinalExcel Workbook Marked as FinalExcel Workbook Marked as Final

When a file is marked as the final version, the workbook will show this

Marking a file as the final version is a less formal way of signaling that a file shouldn’t be changed further. The recipient still has the ability to click Edit Anyway and modify the spreadsheet. Marking a file as the final edition is more like a suggestion, but it’s a great approach if you trust the other file users.

2. Password Protect Your Excel Sheet Structure

Next up, let’s learn how to protect the structure of an Excel workbook. This option will ensure that no sheets are deleted, added, or re-arranged inside of the workbook.

If you want everyone to be able to access the workbook, but limit the changes they can make to a file, this is a great start. This protects the structure of the workbook, and limits how the user can change the sheets inside of it.

To turn on this protection, go to the Review tab on Excel’s ribbon and click on Protect Workbook.

Protect workbook in ExcelProtect workbook in ExcelProtect workbook in Excel

Find the Review tab, click on Protect Workbook, and set a password to protect the structure of your Excel workbook.

Once this option is turned on, the following will go into effect:

  • No new sheets can be added to the workbook.
  • No sheets can be deleted from the workbook.
  • Sheets can no longer be hidden or unhidden from the user’s view.
  • The user can no longer drag and drop the sheet tabs to reorder them in the workbook.

Of course, trusted users can be given the password to unprotect the workbook and modify it. To unprotect a workbook, simply click on the Protect Workbook button again and input the password to unprotect the Excel workbook.

Unprotect workbook in ExcelUnprotect workbook in ExcelUnprotect workbook in Excel

Click Protect Workbook a second time and input the password to re-enable workbook changes.

3. How to Protect Cells in Excel

Now, let’s get down to really detailed methods for protecting a spreadsheet. So far, we’ve been password protecting an entire workbook or the structure of an Excel file. In this section, we dig into how to protect your cells in Excel with specific settings you can apply. We cover how to allow or block certain types of changes to be made to parts of your spreadsheet.

To get started, find Excel’s Review tab, and click on Protect Sheet. On the pop-up window, you’ll see a huge set of options. This window allows you to fine-tune how you want to protect the cells in your Excel spreadsheet. For now, let’s leave the settings at their default.

Protect sheet in ExcelProtect sheet in ExcelProtect sheet in Excel

To protect a sheet, select a tab in your Excel workbook, click on the Review tab and choose the Protect Sheet menu option.

This option allows for very specific protections of your spreadsheet. By default, the options will almost totally lock down the spreadsheet. Let’s add a password so that the sheet is protected. If you press OK at this point, let’s see what happens when you attempt to change a cell.

Error message in ExcelError message in ExcelError message in Excel

After a sheet has been protected, attempting to change a cell will yield this error message. 

Excel throws off an error that the cell is protected, which is exactly what we wanted.

Basically, this option is crucial if you want to ensure that your spreadsheet isn’t changed by others who have access to the file. Using the protect sheet feature is a way that you can selectively protect the spreadsheet.

To unprotect the sheet, simply click on the Protect Sheet button and re-enter the password to remove the protections added to the sheet.

Specific Protections in Excel

Let’s take a second look at the options that show when you start to protect a sheet in Excel workbooks.

Password protect in Excel

Password protect worksheet cells in Excel options.

The Protect Sheet menu lets you refine the options for sheet protection. Each of the boxes on this menu lets the user change slightly more inside of a protected worksheet.

To remove a protection, check the respective box in the list. For example, you could allow the spreadsheet user to Format cells by checking the corresponding box.

Here are two ideas on how you could selectively allow the user to change the spreadsheet:

  • Check the Format cells, columns, and rows boxes to let the user change the visual appearance of cells without modifying the original data.
  • Insert columns and rows could be checked so that the user can add more data, while protecting the original cells.

The important box to leave checked is the Protect worksheet and contents of locked cells box. This protects the data inside of cells. 

When you’re working with crucial financial data or formulas that will be used in making decisions, you have to maintain control of the data and ensure that it doesn’t change. Using these types of targeted protections is an important Excel skill to master.

Recap and Keep Learning More About Excel

Locking up a spreadsheet before you send it is crucial to protecting your valuable data and making sure that it’s not misused. The tips I shared in this tutorial help you maintain control of that data even after your Excel spreadsheet is forwarded and shared.

All of these tips are additional tools and steps to becoming an advanced Excel user. Protecting your workbooks is a specific skill, but there are lots of ways to improve your performance. As always, there’s room to grow your Excel skills further. Here are some helpful Excel tutorials with important skills to master next:

  • PivotTables are a great tool for working with spreadsheet data. Here’s 5 Advanced Excel Pivot Table Techniques to learn now.
  • ExcelZoo has a listing of additional tutorials for protecting your workbooks, sheets, and cells.
  • Condition formatting changes how a cell looks based on what’s inside of it. Here’s a comprehensive Excel tutorial on How to Use Conditional Formatting.

How do you protect your important business data when sharing it? Let me know in the comments section if you use these protection tools or others I may not know about.

Did you find this post useful?

Andrew Childress

I believe that life is too short to do just one thing. In college, I studied Accounting and Finance but continue to scratch my creative itch with my work for Envato Tuts+ and other clients. By day, I enjoy my career in corporate finance, using data and analysis to make decisions.

I cover a variety of topics for Tuts+, including photo editing software like Adobe Lightroom, PowerPoint, Keynote, and more. What I enjoy most is teaching people to use software to solve everyday problems, excel in their career, and complete work efficiently. Feel free to reach out to me on my website.

Содержание

  1. Lock cells to protect them
  2. Need more help?
  3. Protect an Excel file
  4. Need more help?
  5. Protect a workbook
  6. Protect the workbook structure
  7. Protect the workbook structure
  8. Need more help?
  9. Protection and security in Excel
  10. Which level of protection should I use?
  11. Need more help?

Lock cells to protect them

Suppose that your boss wants you to protect an entire workbook, but also wants to be able to change a few cells after you enable protection on the workbook. Before you enabled password protection, you had unlocked some cells in the workbook. Now that your boss is done with the workbook, you can lock these cells.

Follow these steps to lock cells in a worksheet:

Select the cells you want to lock.

On the Home tab, in the Alignment group, click the small arrow to open the Format Cells popup window.

On the Protection tab, select the Locked check box, and then click OK to close the popup.

Note: If you try these steps on a workbook or worksheet you haven’t protected, you’ll see the cells are already locked. This means that the cells are ready to be locked when you protect the workbook or worksheet.

On the Review tab in the ribbon, in the Changes group, select either Protect Sheet or Protect Workbook, and then reapply protection. See Protect a worksheet or Protect a workbook.

Tip: It’s a best practice to unlock any cells that you may want to change before you protect a worksheet or a workbook, but you can also unlock them after you apply protection. To remove protection, simply remove the password.

In addition to protecting workbooks and worksheets, you can also protect formulas.

Excel for the web can’t lock cells or specific areas of a worksheet.

If you want to lock cells or protect specific areas, click Open in Excel and lock cells to protect them or lock or unlock specific areas of a protected worksheet.

Need more help?

You can always ask an expert in the Excel Tech Community or get support in the Answers community.

Источник

Protect an Excel file

To prevent others from accessing data in your Excel files, protect your Excel file with a password.

Note: This topic covers file-level protection only, and not workbook or worksheet protection. To learn the difference between protecting your Excel file, workbook, or a worksheet, see Protection and security in Excel.

Select File > Info.

Select the Protect Workbook box and choose Encrypt with Password.

Enter a password in the Password box, and then select OK.

Confirm the password in the Reenter Password box, and then select OK.

Microsoft cannot retrieve forgotten passwords, so be sure that your password is especially memorable.

There are no restrictions on the passwords you use with regards to length, characters or numbers, but passwords are case-sensitive.

It’s not always secure to distribute password-protected files that contain sensitive information such as credit card numbers.

Be cautious when sharing files or passwords with other users. You still run the risk of passwords them falling into the hands of unintended users. Remember that locking a file with a password does not necessarily protect your file from malicious intent.

Need more help?

You can always ask an expert in the Excel Tech Community or get support in the Answers community.

Источник

Protect a workbook

To prevent other users from viewing hidden worksheets, adding, moving, deleting, or hiding worksheets, and renaming worksheets, you can protect the structure of your Excel workbook with a password.

Note: The screen shots in this article were taken in Excel 2016. If you have a different version your view might be slightly different, but unless otherwise noted, the functionality is the same.

Notes: Protecting the workbook is not the same as protecting an Excel file or a worksheet with a password. See below for more information:

To lock your file so that other users can’t open it, see Protect an Excel file.

To protect certain areas of the data in your worksheet from other users, you have to protect your worksheet. For more information, see Protect a worksheet.

To know the difference between protecting your Excel file, workbook, or a worksheet, see Protection and security in Excel.

Protect the workbook structure

To protect the structure of your workbook, follow these steps:

Click Review > Protect Workbook.

Note: The Windows option is available only in Excel 2007, Excel 2010, Excel for Mac 2011, and Excel 2016 for Mac. Select the Windows option if you want to prevent users from moving, resizing, or closing the workbook window, or hide/unhide windows.

Enter a password in the Password box.

Important: The password is optional. If you do not supply a password, any user can unprotect and change the workbook. If you do enter a password, make sure that you choose a password that is easy to remember. Write your passwords down and store them someplace safe. If you lose them, Excel cannot recover them for you.

Select OK, re-enter the password to confirm it, and then select OK again.

On the Review tab , see the Protect Workbook icon. If it’s highlighted, then the workbook is protected.

If you click on the bottom of a sheet inside your workbook, you will notice that the options to change the workbook structure, such as Insert, Delete, Rename, Move, Copy, Hide, and Unhide sheets are all unavailable.

The Protect Workbook option in the Info menu also indicates that the workbook’s structure is protected. To view this option, click File > Info > Protect Workbook.

Click Review > Protect Workbook. Enter the password and then click OK.

To prevent other users from viewing hidden worksheets, adding, moving, deleting, or hiding worksheets, and renaming worksheets, you can protect the structure of your Excel workbook with a password.

Note: The screen shots in this article were taken in Excel 2016. If you have a different version your view might be slightly different, but unless otherwise noted, the functionality is the same.

Notes: Protecting the workbook is not the same as protecting an Excel file or a worksheet with a password. See below for more information:

To lock your file so that other users can’t open it, see Protect an Excel file.

To protect certain areas of the data in your worksheet from other users, you have to protect your worksheet. For more information, see Protect a worksheet.

To know the difference between protecting your Excel file, workbook, or a worksheet, see Protection and security in Excel.

Protect the workbook structure

To protect the structure of your workbook, follow these steps:

Click Review > Protect Workbook.

Note: The Windows option is available only in Excel 2007, Excel 2010, Excel for Mac 2011, and Excel 2016 for Mac. Select the Windows option if you want to prevent users from moving, resizing, or closing the workbook window, or hide/unhide windows.

Enter a password in the Password box.

The password is optional. If you do not supply a password, any user can unprotect and change the workbook. If you do enter a password, make sure that you choose a password that is easy to remember. Write your passwords down and store them someplace safe. If you lose them, Excel cannot recover them for you.

Passwords in Excel for Mac have a 15-character limit. You cannot open a workbook or document that has been password-protected in the Windows-based version of Excel or if the password is longer than fifteen characters. If you want to open the file in Excel for Mac, ask the Windows-based author to adjust the password length.

Retype the password and click OK.

On the Review tab , see the Protect Workbook icon. If it’s highlighted, then the workbook is protected.

If you click on the bottom of a sheet inside your workbook, you will notice that the options to change the workbook structure, such as Insert, Delete, Rename, Move, Copy, Hide, and Unhide sheets are all unavailable.

Click Review > Protect Workbook. Enter the password and then click OK.

To unprotect a sheet, follow these steps:

Go to the worksheet you want to unprotect.

Go to File > Info > Protect > Unprotect Sheet, or from the Review tab > Changes > Unprotect Sheet.

If the sheet is protected with a password, then enter the password in the Unprotect Sheet dialog box, and click OK.

Excel for the web can open workbooks protected by a password but these files cannot be edited in web. Passwords can’t be added, changed, removed, or recovered from Excel for the web.

If you want to add a password to a workbook you are working on in Excel for the web, and you have Excel desktop application, use the Open in Excel button to open the workbook and password protect the workbook. But going forward, you’ll only be able to view the file on web — to make changes to the workbook, open it in your desktop version of Excel.

Need more help?

You can always ask an expert in the Excel Tech Community or get support in the Answers community.

Источник

Protection and security in Excel

Excel gives you the ability to protect your work, whether it’s to prevent someone from opening a workbook without a password, granting Read-Only access to a workbook, or even just protecting a worksheet so you don’t inadvertently delete any formulas. In this topic we’ll discuss the various ways you can utilize the primary options to protect and distribute your Excel files.

If you forget or lose your password, Microsoft can’t retrieve it for you.

You should not assume that just because you protect a workbook or worksheet with a password that it is secure — you should always think twice before distributing Excel workbooks that could contain sensitive personal information like credit card numbers, Social Security Number, employee identification, to name a few.

Worksheet level protection is not intended as a security feature. It simply prevents users from modifying locked cells within the worksheet.

Following are the different options available for protecting your Excel data:

File-level: This refers to the ability to lock down your Excel file by specifying a password so that users can’t open or modify it. You have two choices here:

File encryption: When you choose this option, you specify a password and lock the Excel file. This prevents other users from opening the file. For more information, see Protect an Excel file.

Setting a password to open or modify a file: You specify a password to open or modify a file. Use this option when you need to give Read-only or edit access to different users. For more information, see Protect an Excel file.

Mark as Final: Use this option if you want to mark your Excel file as the final version and want to prevent any further changes by other users. For more information, see Add or remove protection in your document, workbook, or presentation.

Restrict Access: If your organization has permissions set up using Information Rights Management (IRM), you can apply any of the available IRM permissions to your document. For more information, see Add or remove protection in your document, workbook, or presentation.

Digital signature: You can add digital signatures to your Excel file. For more information, see Add or remove a digital signature in Office files.

Note: To add a digital signature, you need a valid certificate from a certificate authority (CA).

Workbook-level: You can lock the structure of your workbook by specifying a password. Locking the workbook structure prevents other users from adding, moving, deleting, hiding, and renaming worksheets. For more information on protecting workbooks, see Protect a workbook.

Worksheet-level: With sheet protection, you can control how a user can work within worksheets. You can specify what exactly a user can do within a sheet, thereby making sure that none of the important data in your worksheet are affected. For example, you might want a user to only add rows and columns, or only sort and use AutoFilter. Once sheet protection is enabled, you can protect other elements such as cells, ranges, formulas, and ActiveX or Form controls. For more information on protecting worksheets, see Protect a worksheet.

Which level of protection should I use?

To control the level of access users should have to an Excel file, use file-level protection. Let’s say you have a weekly status report of your team members in an Excel file. You don’t want anyone outside your team to be even able to open the file. There are two options available:

If you don’t want others to open your file: You can encrypt the Excel file, which is the most common technique used. This basically means you lock it with a password and nobody except you can open it.

If you want to enable Read-only or editing access to different users: Maybe, you want the managers in your team to be able to edit the weekly status report, but team members should only have Read-only access. You can protect the Excel file by specifying two passwords: one to open, and the other to modify. You can later share the appropriate passwords with the team depending on the access they should be given.

To control how users should work with worksheets inside a your workbook’s structure, use workbook-level protection. Let’s say your status report workbook has multiple worksheets, and each worksheet is named after a team member. You want to make sure each team member can add data to their own worksheet, but not be able to modify any of the worksheets in the workbook, whether it be adding a new worksheet, or moving worksheets around within the workbook.

To control how users should work within an individual worksheet, use worksheet-level protection. Let’s say each worksheet in your status report workbook contains data that is common to all worksheets, like header rows or a specific report layout, and you really don’t want anyone to change it. By protecting your worksheet, you can specify that users can only perform specific functions in a sheet. For example, you can give users the ability to enter data, but keep them from deleting rows or columns, or only insert hyperlinks or sort data.

You can use one or more levels of protection for your Excel data depending on your/your organization’s needs. You can choose to use all of the available options or a combination of options—it’s completely up to the level of security you want for your Excel data. For example, you may choose to encrypt a shared Excel file, as well as enable workbook and worksheet protection, while only using worksheet protection on a personal workbook just so you don’t accidentally delete any formulas.

Need more help?

You can always ask an expert in the Excel Tech Community or get support in the Answers community.

Источник

Protecting and unprotecting sheets is a common action for an Excel user. There is nothing worse than when somebody, who doesn’t know what they’re doing, overtypes essential formulas and cell values. It’s even worse when that person happens to be us; all it takes is one accidental keypress, and suddenly the entire worksheet is filled with errors. In this post, we explore using VBA to protect and unprotect sheets.

Protection is not foolproof but prevents accidental alteration by an unknowing user.

Sheet protection is particularly frustrating as it has to be applied one sheet at a time. If we only need to protect a single sheet, that’s fine. But if we have more than 5 sheets, it is going to take a while. This is why so many people turn to a VBA solution.

The VBA Code Snippets below show how to do most activities related to protecting and unprotecting sheets.

Download the example file: Click the link below to download the example file used for this post:

Adapting the code for your purposes

Unless stated otherwise, every example below is based on one specific worksheet. Each code includes Sheets(“Sheet1”)., this means the action will be applied to that specific sheet. For example, the following protects Sheet1.

Sheets("Sheet1").Protect

But there are lots of ways to reference sheets for protecting or unprotecting. Therefore we can change the syntax to use one of the methods shown below.

Using the active sheet

The active sheet is whichever sheet is currently being used within the Excel window.

ActiveSheet.Protect

Applying a sheet to a variable

If we want to apply protection to a sheet stored as a variable, we could use the following.

Dim ws As Worksheet

Set ws = Sheets("Sheet1")

ws.Protect

Later in the post, we look at code examples to loop through each sheet and apply protection quickly.

Let’s begin with some simple examples to protect and unprotect sheets in Excel.

Protect a sheet without a password

Sub ProtectSheet()

'Protect a worksheet
Sheets("Sheet1").Protect

End Sub

Unprotect a sheet (no password)

Sub UnProtectSheet()

'Unprotect a worksheet
Sheets("Sheet1").Unprotect

End Sub

Protecting and unprotecting with a password

Adding a password to give an extra layer of protection is easy enough with VBA. The password in these examples is hardcoded into the macro; this may not be the best for your scenario. It may be better to apply using a string variable, or capturing user passwords with an InputBox.

VBA Protect sheet with password

Sub ProtectSheetWithPassword()

'Protect worksheet with a password
Sheets("Sheet1").Protect Password:="myPassword"

End Sub

VBA Unprotect sheet with a password

Sub UnProtectSheetWithPassword()

'Unprotect a worksheet with a password
Sheets("Sheet1").Unprotect Password:="myPassword"

End Sub

NOTE – It is not necessary to unprotect, then re-protect a sheet to change the settings. Instead, just protect again with the new settings.

Using a password based on user input

Using a password that is included in the code may partly defeat the benefit of having a password. Therefore, the codes in this section provide examples of using VBA to protect and unprotect based on user input. In both scenarios, clicking Cancel is equivalent to entering no password.

Protect with a user-input password

Sub ProtectSheetWithPasswordFromUser()

'Protect worksheet with a password
Sheets("Sheet1").Protect Password:=InputBox("Enter a protection password:")

End Sub

Unprotect with a user-input password

Sub UnProtectSheetWithPasswordFromUser()

'Protect worksheet with a password
Sheets("Sheet1").Unprotect _
    Password:=InputBox("Enter a protection password:")

End Sub

Catching errors when incorrect password entered

If an incorrect password is provided, the following error message displays.

VBA to protect and unprotect sheets - Incorrect password

The code below catches the error and provides a custom message.

Sub CatchErrorForWrongPassword()

'Keep going even if error found
On Error Resume Next

'Apply the wrong password
Sheets("Sheet1").Unprotect Password:="incorrectPassword"

'Check if an error has occured
If Err.Number <> 0 Then
    MsgBox "The Password Provided is incorrect"
    Exit Sub
End If

'Reset to show normal error messages
On Error GoTo 0

End Sub

If you forget a password, don’t worry, the protection is easy to remove.

Applying protection to different parts of the worksheet

VBA provides the ability to protect 3 aspects of the worksheet:

  • Contents – what you see on the grid
  • Objects – the shapes and charts which are on the face of the grid
  • Scenarios – the scenarios contained in the What If Analysis section of the Ribbon

By default, the standard protect feature will apply all three types of protection at the same time. However, we can be specific about which elements of the worksheet are protected.

Protect contents

Sub ProtectSheetContents()

'Apply worksheet contents protection only
Sheets("Sheet1").Protect Password:="myPassword", _
    DrawingObjects:=False, _
    Contents:=True, _
    Scenarios:=False

End Sub

Protect objects

Sub ProtectSheetObjects()

'Apply worksheet objects protection only
Sheets("Sheet1").Protect Password:="myPassword", _
    DrawingObjects:=True, _
    Contents:=False, _
    Scenarios:=False

End Sub

Protect scenarios

Sub ProtectSheetScenarios()

'Apply worksheet scenario protection only
Sheets("Sheet1").Protect Password:="myPassword", _
    DrawingObjects:=False, _
    Contents:=False, _
    Scenarios:=True

End Sub

Protect contents, objects and scenarios

Sub ProtectSheetAll()

'Apply worksheet protection to contents, objects and scenarios
Sheets("Sheet1").Protect Password:="myPassword", _
    DrawingObjects:=True, _
    Contents:=True, _
    Scenarios:=True

End Sub

Applying protection to multiple sheets

As we have seen, protection is applied one sheet at a time. Therefore, looping is an excellent way to apply settings to a lot of sheets quickly. The examples in this section don’t just apply to Sheet1, as the previous examples have, but include all worksheets or all selected worksheets.

Protect all worksheets in the active workbook

Sub ProtectAllWorksheets()

'Create a variable to hold worksheets
Dim ws As Worksheet

'Loop through each worksheet in the active workbook
For Each ws In ActiveWorkbook.Worksheets

    'Protect each worksheet
    ws.Protect Password:="myPassword"

Next ws

End Sub

Protect the selected sheets in the active workbook

Sub ProtectSelectedWorksheets()

Dim ws As Worksheet
Dim sheetArray As Variant

'Capture the selected sheets
Set sheetArray = ActiveWindow.SelectedSheets

'Loop through each worksheet in the active workbook
For Each ws In sheetArray

    On Error Resume Next

    'Select the worksheet
    ws.Select

    'Protect each worksheet
    ws.Protect Password:="myPassword"

    On Error GoTo 0

Next ws

sheetArray.Select

End Sub

Unprotect all sheets in active workbook

Sub UnprotectAllWorksheets()

'Create a variable to hold worksheets
Dim ws As Worksheet

'Loop through each worksheet in the active workbook
For Each ws In ActiveWorkbook.Worksheets

'Unprotect each worksheet
ws.Unprotect Password:="myPassword"

Next ws

End Sub

Checking if a worksheet is protected

The codes in this section check if each type of protection has been applied.

Check if Sheet contents is protected

Sub CheckIfSheetContentsProtected()

'Check if worksheets contents is protected
If Sheets("Sheet1").ProtectContents Then MsgBox "Protected Contents"

End Sub

Check if Sheet objects are protected

Sub CheckIfSheetObjectsProtected()

'Check if worksheet objects are protected
If Sheets("Sheet1").ProtectDrawingObjects Then MsgBox "Protected Objects"

End Sub

Check if Sheet scenarios are protected

Sub CheckIfSheetScenariosProtected()

'Check if worksheet scenarios are protected
If Sheets("Sheet1").ProtectScenarios Then MsgBox "Protected Scenarios"

End Sub

Changing the locked or unlocked status of cells, objects and scenarios

When a sheet is protected, unlocked items can still be edited. The following codes demonstrate how to lock and unlock ranges, cells, charts, shapes and scenarios.

When the sheet is unprotected, the lock setting has no impact. Each object becomes locked on protection.

All the examples in this section set each object/item to lock when protected. To set as unlocked, change the value to False.

Lock a cell

Sub LockACell()

'Changing the options to lock or unlock cells
Sheets("Sheet1").Range("A1").Locked = True

End Sub

Lock all cells

Sub LockAllCells()

'Changing the options to lock or unlock cells all cells
Sheets("Sheet1").Cells.Locked = True

End Sub

Lock a chart

Sub LockAChart()

'Changing the options to lock or unlock charts
Sheets("Sheet1").ChartObjects("Chart 1").Locked = True

End Sub

Lock a shape

Sub LockAShape()

'Changing the option to lock or unlock shapes
Sheets("Sheet1").Shapes("Rectangle 1").Locked = True

End Sub

Lock a Scenario

Sub LockAScenario()

'Changing the option to lock or unlock a scenario
Sheets("Sheet1").Scenarios("scenarioName").Locked = True

End Sub

Allowing actions to be performed even when protected

Even when protected, we can allow specific operations, such as inserting rows, formatting cells, sorting, etc. These are the same options as found when manually protecting the sheet.

Standard protection settings

Allow sheet actions when protected

Sub AllowSheetActionsWhenProtected()

'Allowing certain actions even if the worksheet is protected
Sheets("Sheet1").Protect Password:="myPassword", _
    DrawingObjects:=False, _
    Contents:=True, _
    Scenarios:=False, _
    AllowFormattingCells:=True, _
    AllowFormattingColumns:=True, _
    AllowFormattingRows:=True, _
    AllowInsertingColumns:=False, _
    AllowInsertingRows:=False, _
    AllowInsertingHyperlinks:=False, _
    AllowDeletingColumns:=True, _
    AllowDeletingRows:=True, _
    AllowSorting:=False, _
    AllowFiltering:=False, _
    AllowUsingPivotTables:=False

End Sub

Allow selection of any cells

Sub AllowSelectionAnyCells()

'Allowing selection of locked or unlocked cells
Sheets("Sheet1").EnableSelection = xlNoRestrictions

End Sub

Allow selection of unlocked cells

Sub AllowSelectionUnlockedCells()

'Allowing selection of unlocked cells only
Sheets("Sheet1").EnableSelection = xlUnlockedCells

End Sub

Don’t allow selection of any cells

Sub NoSelectionAllowed()

'Do not allow selection of any cells
Sheets("Sheet1").EnableSelection = xlNoSelection

End Sub

Allowing VBA code to make changes, even when protected

Even when protected, we still want our macros to make changes to the sheet. The following VBA code changes the setting to allow macros to make changes to a protected sheet.

Sub AllowVBAChangesOnProtectedSheet()

'Enable changes to worksheet by VBA code, even if protected
Sheets("Sheet1").Protect Password:="myPassword", _
    UserInterfaceOnly:=True

End Sub

Unfortunately, this setting is not saved within the workbook. It needs to be run every time the workbook opens. Therefore, calling the code in the Workbook_Open event of the Workbook module is probably the best option.

Allowing the use of the Group and Ungroup feature

To enable users to make use of the Group and Ungroup feature of protected sheets, we need to allow changes to the user interface and enable outlining.

Sub AllowGroupingAndUngroupOnProtectedSheet()

'Allow user to group and ungroup whilst protected
Sheets("Sheet1").Protect Password:="myPassword", _
    UserInterfaceOnly:=True

Sheets("Sheets1").EnableOutlining = True

End Sub

As noted above the UserInterfaceOnly setting is not stored in the workbook; therefore, it needs to be run every time the workbook opens.

Conclusion

Wow! That was a lot of code examples; hopefully, this covers everything you would ever need for using VBA to protect and unprotect sheets.

Related posts:

  • Office Scripts – Workbook & worksheet protection
  • VBA Code to Password Protect an Excel file
  • VBA code to Protect and Unprotect Workbooks

Headshot Round

About the author

Hey, I’m Mark, and I run Excel Off The Grid.

My parents tell me that at the age of 7 I declared I was going to become a qualified accountant. I was either psychic or had no imagination, as that is exactly what happened. However, it wasn’t until I was 35 that my journey really began.

In 2015, I started a new job, for which I was regularly working after 10pm. As a result, I rarely saw my children during the week. So, I started searching for the secrets to automating Excel. I discovered that by building a small number of simple tools, I could combine them together in different ways to automate nearly all my regular tasks. This meant I could work less hours (and I got pay raises!). Today, I teach these techniques to other professionals in our training program so they too can spend less time at work (and more time with their children and doing the things they love).


Do you need help adapting this post to your needs?

I’m guessing the examples in this post don’t exactly match your situation. We all use Excel differently, so it’s impossible to write a post that will meet everybody’s needs. By taking the time to understand the techniques and principles in this post (and elsewhere on this site), you should be able to adapt it to your needs.

But, if you’re still struggling you should:

  1. Read other blogs, or watch YouTube videos on the same topic. You will benefit much more by discovering your own solutions.
  2. Ask the ‘Excel Ninja’ in your office. It’s amazing what things other people know.
  3. Ask a question in a forum like Mr Excel, or the Microsoft Answers Community. Remember, the people on these forums are generally giving their time for free. So take care to craft your question, make sure it’s clear and concise.  List all the things you’ve tried, and provide screenshots, code segments and example workbooks.
  4. Use Excel Rescue, who are my consultancy partner. They help by providing solutions to smaller Excel problems.

What next?
Don’t go yet, there is plenty more to learn on Excel Off The Grid.  Check out the latest posts:

Понравилась статья? Поделить с друзьями:
  • Pronouncing the longest word
  • Protect excel file from opening with password
  • Pronounce the word world
  • Protect all sheet excel
  • Pronounce the word vowel