Protecting Excel Worksheets and Workbooks

29 Jun, 2021
Sometimes while sharing your spreadsheets you may not want the receiver to change the content of your worksheet or perhaps change only specific content and leave the rest untouched. To protect your worksheet from being edited by other people, Excel offers a protection feature. By following a couple of steps you can set protection to your work.
Protect an entire workbook from editing: A workbook can be protected by encrypting the workbook with a password, making the workbook read-only, or protecting the structure of a workbook.
To prevent other people from accessing your Excel files, protect them with a password. Head on to the file menu and fo the following: 
Step 1: Select File > Info.
Step 2: Select the Protect Workbook box and choose Encrypt with Password.
Step 3: Enter a password in the Password box, and then select OK.
Step 4: Confirm the password in the Re-enter Password box and then select OK.
TIP: Excel can’t retrieve your password once forgotten hence it’s advised to keep it easy to remember.
By making a workbook read only the user can read the content of the file and then enable editing if the user wishes to make changes, it gives the user a hint to be cautious about editing the file.
To make a workbook read-only open the Excel file you want to protect and then :
Step 1: Head on to File>info 
Step 2: Select the Protect Workbook box and choose Always open Read-Only.
Step 3: Open the file and a warning will be displayed stating the author prefers the file to be opened in read-only mode. This makes the user aware of the author’s concerns.
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. 
Step 1: Click on Review tab>Protect workbook (under Changes ).
Step 2: Enter a password in the password box.
Step 3: Click ok and re-enter the password to confirm and hit OK again.
To remove the password from the workbook Head on to Review > Protect Workbook > type in the password and the workbook will be free from the password.
To protect the Workbook from editing follow the below steps:
Step 1: Open the worksheet you want to protect.
Step 2: Head on to Review tab > Protect sheet. 
Step 3: This opens a project sheet dialog and prompts you to enter a password for the sheet. You can check the boxes you want the user to be able to edit after protection and uncheck the rest.
Step 4: Hit OK and confirm password  (don’t lose this password). 
Your sheet is now protected, try typing into the sheet and see what excel prompts!
As a developer if you want to make changes to your sheet you can hit the unprotect sheet under the review tab>enter the password> make the changes.
By default, every single cell in an Excel worksheet is locked. So if you head on to the Review tab and hit protected every single cell in the worksheet gets protected and no one can make any changes. But if you want the user  to be able to edit certain cells  and leave the rest unedited then follow these steps :
Step 1: Open the file you want to protect. 
Step 2: Select the cells from the file that you want the users to be able to edit and make changes to(cells you want to unlock).
Step 3: Then under the font section click on the arrow pointing downwards icon on the bottom-right (called font settings)
Step 4: As the Format cells dialog box opens up, head on to Protection, turn off the locked property for the selected cells, and hit ok.
These cells are no longer locked and can be edited by the user. Deciding which cells should be locked and which shouldn’t is important while protecting the sheets.
Step 5: Head on to the Review tab > Protect sheet. This opens a protect sheet dialog and prompts you to enter a password for the sheet. You can check the boxes you want the user to be able to edit after protection and uncheck the rest.
Step 6: Hit OK and confirm password  (don’t lose this password). 
Step 7: Click ok and re-enter the password to confirm and hit OK again.
According to the situation at hand, you can protect your worksheet or workbook in one of the many ways.
Excel
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.