Sub topic 7
Leaving Input Cells Editable on a Protected Sheet
This chapter assumes you know how to select cells, use sheet tabs, and write ranges in A1 notation such as B2:B20. It also assumes you understand that viewers, commenters, and editors have different file access levels. The Apps Script example assumes basic JavaScript.
A protected sheet blocks edits to the sheet by default. You can create exceptions, called unprotected ranges, for cells where people must enter data. This pattern works well for forms, budgets, trackers, and review sheets. Formula columns, labels, and totals stay protected while input cells remain editable.
Protect a sheet and add input exceptions
Suppose a sheet named Budget has formulas and labels in most cells. Users should enter amounts only in B2:B20.
- Open the Budget sheet.
- Select Data > Protect sheets and ranges.
- In the side panel, select Sheet.
- Choose the Budget sheet.
- Select Except certain cells.
- Enter
B2:B20as the exception range. - Select Set permissions.
- Choose who can edit the protected sheet.
- Save the protection.
The exception does not grant access to people who cannot edit the file. It only prevents this particular protection from blocking the specified cells. A viewer still cannot type into the cells because the file-level access is more restrictive.
You can add multiple exception ranges. For example, a data-entry sheet might leave B2:B20 and D2:D20 editable while protecting every other cell.
Check the access model
Protection has two related settings:
- File access determines whether a person is a viewer, commenter, or editor.
- Protection settings determine which editors may change a protected sheet or range.
For example, if a sheet is protected and B2:B20 is unprotected, every person who already has edit access can normally change those input cells. The protection does not turn those cells into a separate sharing system.
If only selected editors should be able to edit the sheet, use Set permissions on the protection and specify those people. Review the protection carefully when the spreadsheet's sharing list changes.
| File access | Can edit an unprotected input range? |
|---|---|
| Viewer | No |
| Commenter | No |
| Editor | Usually yes, subject to the file and protection settings |
Create the same pattern with Apps Script
Apps Script can protect a whole sheet and define its editable exceptions. The following function protects the Budget sheet but leaves B2:B20 editable by anyone who already has edit access to the spreadsheet.
function protectSheetExceptInputs() {
const sheet = SpreadsheetApp.getActive().getSheetByName('Budget');
const protection = sheet.protect().setDescription('Budget sheet');
protection.setUnprotectedRanges([sheet.getRange('B2:B20')]);
}The setUnprotectedRanges method accepts an array of range objects. You can provide more than one range:
function protectBudgetInputs() {
const sheet = SpreadsheetApp.getActive().getSheetByName('Budget');
const protection = sheet.protect().setDescription('Budget inputs');
protection.setUnprotectedRanges([
sheet.getRange('B2:B20'),
sheet.getRange('D2:D20')
]);
}This script does not automatically remove other editors from the protection. If the protection must restrict editing to particular accounts, configure its editors explicitly and test the result with a non-owner account. Avoid assuming that a successful script run proves that the intended users have the intended access.
Test and review the exceptions
After creating a protection, test each type of cell:
- Enter a valid value in an unprotected input cell.
- Try to change a formula or label outside the exceptions.
- Try to paste across both protected and unprotected cells.
- Check that formulas still calculate after an input changes.
- Test with an ordinary editor account when possible.
Keep input ranges narrow. If users need to add rows, protect a larger planned input area or use a separate input sheet. Record the purpose of each protection in its description, such as Budget inputs or Review formulas. Review protections when the layout, owners, or sharing list changes.
Exercise
A Budget sheet should protect all formulas but allow editors to enter values in B2:B20 and D2:D20. What should you configure?
Show answer
Protect the entire Budget sheet and set B2:B20 and D2:D20 as unprotected ranges. Confirm that the intended users already have editor access to the file.