Sub topic 6
Protecting an Entire Sheet
Assume that you can use Google Sheets, identify ranges with A1 notation, and understand the difference between viewers, commenters, and editors. This chapter focuses on protecting a whole sheet while leaving selected cells available for input.
What sheet protection does
Sheet protection restricts which editors can change cells on a sheet. It does not hide the sheet, encrypt its contents, or change the file's sharing settings. A person with view access can still read the sheet, and an editor may still be able to copy data if the file's sharing policy allows it.
A protected sheet is useful when most cells contain formulas, labels, or approved values, but a small area must remain editable. For example, a budget sheet might protect the entire Budget tab while leaving B2:B20 available for expense entries.
Protection works within the file's existing access model:
| File access | Effect of sheet protection |
|---|---|
| Viewer or commenter | Cannot edit cells, whether protected or not |
| Editor without permission for the protection | Cannot edit protected cells |
| Editor allowed by the protection | Can edit protected cells |
| File owner | Generally retains administrative control over protections |
Protection is therefore an editing safeguard, not a replacement for careful sharing decisions.
Protect a sheet in the interface
- Open the sheet tab that you want to protect.
- Select Data > Protect sheets and ranges.
- In the side panel, select Sheet.
- Confirm the sheet name. Do not select Except certain cells yet unless you need input areas.
- Select Set permissions.
- Choose one of these options:
- Only you restricts editing to you and any users the file system requires to retain access.
- Custom lets you select specific editors who may change the protected sheet.
- Show a warning when editing this range allows edits after an acknowledgment instead of blocking them.
- Save the protection.
When a user tries to edit a blocked cell, Sheets displays a message instead of applying the change. Existing values and formulas remain unchanged unless an authorized user edits them.
Leave input cells editable
A protected sheet can contain unprotected exceptions. In the protection side panel, select Except certain cells, then enter each editable range using A1 notation. For example, B2:B20 leaves one vertical input area open while the rest of the sheet remains protected.
Use narrow exceptions. If users need to enter dates and amounts, protect the headings, formulas, and totals, then leave only the intended entry cells unprotected. An exception means that editors who already have edit access to the file can change those cells. It does not grant access to viewers or commenters.
You can add multiple ranges, such as B2:B20 and D2:D20. Review whether the ranges include blank rows, formulas, or helper cells. A broad exception such as A:Z effectively defeats the sheet protection.
Create the same protection with Apps Script
Apps Script can apply a sheet protection repeatedly. The following function protects the Budget sheet and leaves B2:B20 editable for existing spreadsheet editors.
function protectBudgetSheetExceptInputs() {
const sheet = SpreadsheetApp.getActive()
.getSheetByName('Budget');
if (!sheet) {
throw new Error('The Budget sheet was not found.');
}
const protection = sheet.protect()
.setDescription('Budget sheet');
protection.setUnprotectedRanges([
sheet.getRange('B2:B20')
]);
}This code does not make B2:B20 public. It only makes that range exempt from this sheet protection. The spreadsheet's normal sharing permissions still apply.
Verify and review the design
After creating a protection, test it with an account that has editor access but is not an allowed protection editor. Check that:
- Formula and heading cells cannot be changed.
- The intended input range can be changed.
- Viewers and commenters still have the expected access.
- The protection covers the correct sheet tab.
- No exception overlaps a formula or total.
Exercise
You need to protect every cell on the Budget sheet except the user-entry cells in B2:B20. What should you configure?
Show answer
Protect the Budget sheet and add B2:B20 as an unprotected exception. The exception keeps that range editable for people who already have editor access to the file.