Sub topic 2
Showing a warning instead of blocking edits
This chapter assumes you know cells, ranges, A1 notation, and sheet tabs. You should also understand that a shared spreadsheet gives people viewer, commenter, or editor access. Protection applies on top of that access, so only people with edit access can be stopped or warned.
Showing a warning instead of blocking edits
A warning-only protection asks the editor to confirm before changing a range. It does not block the edit.
- Select the range, then choose Data > Protect sheets and ranges.
- Enter a description, such as "Calculated column."
- Select Set permissions, then choose Show a warning when editing this range.
- Select Done.
Use a warning when you want to catch accidental changes but still allow deliberate ones.
function warnOnEdit() {
const range = SpreadsheetApp.getActiveSheet().getRange('D2:D100');
range.protect()
.setDescription('Calculated column')
.setWarningOnly(true);
}