Sub topic 10
Protecting Sheets and Allowing Edits to Specific Ranges
This chapter assumes you can already save a workbook to OneDrive or SharePoint, share it with edit permission, and see co-authors' presence indicators. Here you will limit what editors can change, so shared workbooks stay safe when several people work in them.
Why protection matters in a shared workbook
Edit permission on a sharing link lets someone change any cell. Sheet protection adds a second layer inside the file. It locks cells so that formulas, headers, and lookup tables stay intact, while the cells people should fill in stay open.
The two layers do different jobs:
| Layer | Set in | Controls |
|---|---|---|
| Link permission | Share dialog | Who can open or edit the file |
| Sheet protection | Review tab | Which cells an editor can change |
How locking works
Every cell has a Locked setting, and it is on by default. The setting does nothing until you protect the sheet. So the process has two steps: unlock the cells people may edit, then protect the sheet.
- Select the input cells, such as the rows where team members enter hours.
- Press Ctrl+1 to open Format Cells, go to the Protection tab, and clear Locked.
- On the Review tab, choose Protect Sheet.
- Choose the actions you still want to allow, such as formatting columns or sorting. Then select OK.
You can add a password. It is optional, and it is not strong security. If you forget it, you cannot remove protection from the Excel interface.
Allowing edits to specific ranges
Allow Edit Ranges lets you open some ranges to some people, even when the sheet is protected. You find it on the Review tab, under Allow Edit Ranges.
- Select New, then enter a title and the cells in Refers to cells.
- Set a Range password, or choose Permissions to name users.
- Select OK, then choose Protect Sheet to switch protection on.
Ranges must be defined before you protect the sheet. The Allow Edit Ranges button is unavailable on a sheet that is already protected.
Protection and co-authoring
Protected sheets work with co-authoring. Several people can edit the unlocked cells at once, and AutoSave keeps them in sync. A few points are worth knowing:
- Protection applies to everyone with edit access, including you. Use Unprotect Sheet when you need to change locked cells.
- Only one person should change protection settings at a time. Do this when others are out of the file.
- Excel for the web has limited support for changing protection settings. Set them in the desktop app.
- Protect Workbook, on the Review tab, locks the sheet structure. It stops people from adding, deleting, renaming, or moving sheets.
Checking protection with VBA
This macro lists which worksheets in the active workbook are protected. It uses the ProtectContents property.
Sub ListProtectedSheets()
Dim ws As Worksheet
Dim result As String
For Each ws In ActiveWorkbook.Worksheets
If ws.ProtectContents Then
result = result & ws.Name & ": protected" & vbCrLf
Else
result = result & ws.Name & ": not protected" & vbCrLf
End If
Next ws
MsgBox result
End SubCommon mistakes
- Protecting the sheet before unlocking input cells. Everyone then sees "The cell or chart you're trying to change is on a protected sheet."
- Relying on a protection password to keep data private. Anyone with view access can still read the data.
- Forgetting that hidden formulas can be hidden only on the Protection tab, and only take effect after protection is on.
Exercise
You share a budget workbook with five colleagues who have edit access. You want them to type only in cells C5:C20, and leave the formulas in column D untouched. What two steps do you take, and in what order?
Show answer
First, select C5:C20 and clear the Locked setting on the Protection tab of Format Cells. Second, use Review > Protect Sheet. The Locked setting has no effect until the sheet is protected, and the formulas in column D stay locked because Locked is on by default.
Exercise
You need to give only the finance team access to a range on a protected sheet. Why should you test with a second account if you plan to use named-user permissions?
Show answer
Named-user permissions in Allow Edit Ranges depend on Windows domain accounts and often do not work with Microsoft 365 sign-ins, so you must confirm they actually work for cloud-shared files.