Sub topic 1
What Protection Is For and When to Use It
Prerequisites
This chapter assumes you already know the following:
- Basic Google Sheets use: cells, ranges, and sheet tabs.
- A1 notation, such as
A1:E1for a header row orB2:B20for an input column. - That a spreadsheet can be shared with viewers, commenters, and editors.
You do not need to write code for this chapter. Later chapters use JavaScript (Apps Script) and the Sheets API. This chapter builds the working model that those chapters rely on.
The problem protection solves
A shared spreadsheet fails in quiet ways. Nobody has to act maliciously. A colleague sorts one column and leaves the rest of the table in its old order. Someone types a number over a formula. Another person deletes a helper column that three reports depend on. Each of these edits is legal, because every person with edit access can change every cell.
Protection narrows that default. Protection is a rule attached to a range or a whole sheet that limits who may change it, or that asks for confirmation before a change. It gives you a way to say "this part is not meant to be edited casually" and have Google Sheets enforce that rule inside the editor.
Protection works at the level of cells and sheets. File sharing works at the level of the whole spreadsheet. The two features complement each other. File sharing decides who can open the file and what they can do in general. Protection then carves out regions inside the file where some of those people are held back.
What protection restricts
When a range or sheet is protected, Google Sheets checks each edit against the rule. Depending on how the protection is set up, one of two things happens.
- Restricted protection: Only the people on the protection's editor list can change the protected area. Everyone else who has edit access to the file can still see the cells, but their edit attempts are rejected.
- Warning-only protection: Everyone with edit access to the file can change the area, but they see a confirmation prompt first. Nothing is blocked.
A protection can cover:
- A range, such as a header row or a column of calculated values.
- An entire sheet (one tab), optionally with some ranges left unprotected so people can still type in them.
Protection restricts changes to content, such as typing, pasting, clearing, and deleting values or formulas in the protected cells. It also covers edits that would change the protected area, such as deleting a protected row or sorting a range that includes protected cells. Whole-sheet protection also covers structural actions on that tab, such as renaming or deleting the sheet.
What protection does not restrict
This is the part of the model that causes the most mistakes, so it comes early.
- Reading. Anyone who can open the file can see protected cells and the formulas inside them. Protection does not hide anything.
- Copying. A viewer or editor can usually copy the contents of a protected range into another spreadsheet.
- The owner and protection editors. The file owner and anyone on a protection's editor list can still edit the area. That is the purpose of the list.
- Access changes. Protection does not decide who has access to the file. File sharing does.
Because protection does not hide data, never use it to keep a secret. If a value must not be seen by some people, keep it out of the file they can open. A later chapter on limitations covers this in detail.
Two modes, one decision
The first design choice for every protection is whether to block or to warn. The table below summarizes the trade-off.
| Mode | Who can edit | What other editors see | Good for |
|---|---|---|---|
| Restricted | Owner and the listed protection editors | An error when they try to change the area | Headers, formulas, lookup tables, totals |
| Warning-only | Everyone with edit access | A confirmation prompt before the change applies | Calculated columns that rarely need changes, areas where you trust people but want a pause |
Restricted protection gives a firm guarantee within the editor. Warning-only protection is a nudge. It suits cases where you want people to think twice, but a legitimate edit is sometimes needed and you do not want to maintain an editor list.
A common mistake is choosing warning-only protection for something that must not change, then assuming it is safe. A person can click through the prompt. If the area truly must stay fixed, use restricted protection.
When to use protection
Protection fits when part of a spreadsheet has a stable structure and other parts are meant to change. Typical cases:
- Header rows. Scripts, pivot tables, and lookups often refer to header labels. Renaming a header can break them.
- Formula columns. A column of computed values such as totals, tax, or status flags should not be overwritten with typed numbers.
- Reference data. Lookup tables for rates, categories, or codes feed other sheets. Changes should come from a small group.
- Input forms inside a sheet. A layout with labelled cells and a few input cells works well when the whole sheet is protected except the input cells.
- Dashboards. A summary tab that others read should not change by accident when people edit data tabs.
- Handover and templates. When you give a template to a team, protection keeps the structure intact while people fill it in.
When protection is the wrong tool
Protection is also easy to over-apply. Consider other approaches in these situations:
- You need to hide data from some people. Share a different file, or share only the data they should see. Protection does not hide cells.
- You need to control who can open the file. Use file sharing settings.
- You want to prevent bad values in an input cell. Data validation checks what is typed. Protection checks who may type. They solve different problems and work well together.
- You need an audit trail of changes. Version history and the cell edit history show who changed what. Protection prevents some changes but does not record them.
- Only one person edits the file. Protection adds friction without much benefit, though it can still guard against your own mistakes.
Too many protections have a cost. Each one is another rule someone has to understand and maintain. A spreadsheet with dozens of small protections is hard to reason about, and people tend to ask the owner to remove them. A small number of well-described protections works better.
A working model of how an edit is checked
When someone tries to change a cell, the editor effectively asks a few questions in order.
Two points follow from this model.
- File access is checked first. Protection can only narrow what edit access already allows. It cannot give someone edit rights that the file does not grant. A person with view-only access cannot be made an editor of a protected range.
- Protections are evaluated per area. A sheet can have a protection on its header, a different one on a calculated column, and a third that covers a whole other tab. Each has its own description and its own editor list.
A worked example
Suppose you manage a monthly budget sheet shared with five teammates. The layout is:
- Row 1 holds the headers
Category,Planned,Actual,Variance, andNotesinA1:E1. - Column D holds a formula,
=C2-B2, inD2:D100. - Column B holds planned amounts that you set at the start of the month.
- Column C holds actual spending that teammates fill in.
You want each part to be handled in the way that suits it.
| Area | Purpose | Suggested protection |
|---|---|---|
| `A1:E1` | Headers used by a pivot table | Restricted, editors: you only |
| `D2:D100` | Variance formula | Warning-only, so a teammate can fix a row but is warned |
| `B2:B100` | Planned amounts | Restricted, editors: you and one co-owner |
| `C2:C100` | Actual spending | Not protected |
| `E2:E100` | Free-text notes | Not protected |
This gives teammates freedom where they need it and a barrier where an accidental change would cost the most. Each protection also gets a description such as "Header row" or "Variance formula". Descriptions appear in the protections list, and they are what you will read six months later when you wonder why a cell refuses an edit.
The alternative design protects the whole sheet and leaves C2:C100 and E2:E100 unprotected. Both designs work. The range-by-range design is better when most of the sheet is editable. The whole-sheet design is better when most of the sheet is fixed. Later chapters show both in the interface and in code.
Where protections live and how you will create them
You can create and manage protections in three ways. The rest of the tutorial covers each one.
- The interface: The Data menu has a Protect sheets and ranges entry. It opens a side panel where you add a range or sheet, set a description, and choose who can edit. This is the best way to learn the model.
- Apps Script: The
RangeandSheetclasses have aprotect()method that returns aProtectionobject. You can set the description, change editors, switch to warning-only, list existing protections, and remove them. This suits repeated setup, such as copies of a template. - The Sheets API: A
spreadsheets.batchUpdaterequest withaddProtectedRangecreates a protected range from outside the spreadsheet. Row and column indexes are zero-based, and end indexes are exclusive.
As a preview, the Apps Script below protects a header row so that only the user running the script can edit it.
function protectHeaderRow() {
const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:E1');
const protection = range.protect().setDescription('Header row');
// Restrict editing to the user running the script (and the file owner).
protection.removeEditors(protection.getEditors());
protection.addEditor(Session.getEffectiveUser());
if (protection.canDomainEdit()) {
protection.setDomainEdit(false);
}
}The script creates the protection, removes the default editors, adds the current user, and turns off domain-wide editing when that option applies. You do not need to follow each call yet. The point for now is that the same rule you can set by clicking in the side panel can also be written as code.
Common mistakes at this stage
- Treating protection as hiding. Protected cells remain visible and copyable.
- Leaving descriptions blank. An unlabeled protection is hard to audit later.
- Protecting too much. If most cells are protected, teammates ask for exceptions, and the owner ends up editing on their behalf.
- Using warning-only for fixed structure. A prompt is easy to dismiss.
- Forgetting that the owner is not blocked. If you test a protection while signed in as the owner, you will not see the error that others see. Test with a second account that has edit access.
- Confusing file access with protection. If a teammate cannot edit anything, check file sharing before you look at protections.
Summary of the working model
- Protection narrows what edit access allows, at the level of a range or a sheet.
- It either blocks edits by everyone except listed editors or shows a warning before an edit.
- It does not hide, encrypt, or stop copying of data.
- File access comes first, and protection is a second layer on top of it.
- Use it for headers, formulas, reference data, and fixed layouts. Use other tools for hiding data, validating input, or tracking history.
Exercise
A teammate has edit access to your budget spreadsheet. You protect the formula column D2:D100 in restricted mode and list only yourself as an editor. The teammate says they can still see the formulas and can copy the column into their own spreadsheet. Is the protection broken? Explain, and say what you would use if the formulas had to stay private.
Show answer
The protection is working as designed. Restricted protection stops the teammate from changing D2:D100, but it does not hide cells and it does not stop copying. Anyone who can open the file can read the formulas and values. If the formulas had to stay private, protection is the wrong tool. You would keep the sensitive calculations in a separate file that the teammate cannot open, and share only the results they need, for example as a copy that holds values instead of formulas.
Exercise
Your team's sheet has a "Status" column whose values are calculated by a formula. Occasionally someone has a good reason to override a status by hand. You want to stop accidental typing over the formula without maintaining an editor list. Which protection mode fits, and what is its main weakness?
Show answer
Warning-only protection fits. Everyone with edit access can still change the cells, but they see a confirmation prompt first, which stops accidental overwrites and allows deliberate overrides without an editor list. Its weakness is that the prompt can be dismissed, so it does not guarantee the formulas stay intact. If the column must not change, use restricted protection instead.
Exercise
You protect the header row in restricted mode, listing only yourself, and then test by editing the header while signed in as the file owner. The edit succeeds. A colleague reports that they are blocked. Why do the results differ, and how should you test next time?
Show answer
The file owner can always edit protected areas, and you are also on the editor list, so your edit is allowed. The colleague has edit access to the file but is not a protection editor, so their edit is rejected. To test the rule as other people experience it, sign in with a second account that has edit access to the file but is not on the protection's editor list, and try the edit from there.