Sub topic 6
Protecting Sheets and Ranges
Assume you can open a Google Sheet, use its menus, and identify cell ranges. This chapter uses terms such as editor and owner from the sharing model. Protection controls editing inside a spreadsheet. It does not replace file sharing permissions.
When to protect a sheet or range
Use protection when people need access to a spreadsheet but should not change certain content.
Common examples include:
- Protecting formulas while leaving input cells editable.
- Protecting a summary sheet while allowing edits on a data-entry sheet.
- Preventing accidental changes to headings, totals, or lookup tables.
- Allowing a team to edit one section of a sheet but not another.
A protected range applies to selected cells. A protected sheet applies to the whole tab. A protected sheet can include exceptions, called unprotected ranges, where other editors may still enter data.
Protection does not encrypt cells. Editors may still be able to copy, export, print, or make a copy unless separate sharing controls limit those actions.
Protect a range or sheet in the interface
- Select the cells you want to protect. To protect a complete tab, open that tab without selecting a range.
- Choose Data > Protect sheets and ranges.
- In the side panel, choose Range or Sheet.
- Add a description, such as
Calculated totals. - Select Set permissions.
- Choose who can edit the protected area:
- Only you.
- Custom people.
- A suitable organization or domain option, if your account provides one.
- Save the rule.
For a sheet protection, select Except certain cells if users need to edit specific areas. For example, protect the Summary sheet but leave B3:B20 open for notes.
A permission rule can be strict or advisory:
- Restrict editing prevents unauthorized editors from changing the cells.
- Show a warning allows an editor to continue after acknowledging a warning.
Use restriction for formulas or values that must remain unchanged. Use a warning when accidental edits are undesirable but still acceptable.
Use several protections carefully
A sheet can contain overlapping protected ranges. Review the rules when behavior seems unexpected. A user might be allowed to edit one smaller range even though a larger sheet protection exists, or a newly added row might not be included in the original range.
Protection also does not automatically protect new sheets, copied tabs, or newly inserted columns outside the selected range. Recheck the protected areas after changing the spreadsheet structure.
Protect a range with Apps Script
Apps Script is Google’s JavaScript-based automation tool for Google Workspace. The following function protects a range and gives one named person editing permission:
function protectTotals() {
const sheet = SpreadsheetApp.getActiveSpreadsheet()
.getSheetByName('Summary');
const range = sheet.getRange('B2:F20');
const protection = range.protect()
.setDescription('Calculated totals');
protection.setWarningOnly(false);
protection.removeEditors(protection.getEditors());
protection.addEditor('[email protected]');
}Replace the sheet name and email address. The account running the script must have enough authority to change protection. The first run asks for authorization because the script accesses the spreadsheet.
To protect a whole tab instead, replace range.protect() with sheet.protect(). If you want a warning rather than a restriction, use protection.setWarningOnly(true) and do not rely on the rule to enforce a boundary.
Test and maintain protection
After creating a rule, test it with an account that should not edit the area. Confirm that an authorized person can still change it. Review protection rules when staff, formulas, or sheet layouts change.
Exercise
You need a sheet where a team can enter values in C2:C50 but cannot change formulas in A2:B50. What protection setup should you use?
Show answer
Protect the sheet or the formula range A2:B50 with restricted editing, and leave C2:C50 unprotected. Give the team editor access to the spreadsheet so they can enter values in the open range.