Diagnostic reference
You are trying to edit a protected cell or object
Fix Exception: You are trying to edit a protected cell or object and Action not allowed in Google Sheets Apps Script using installable triggers or permissions.
Updated December 6, 2026
Apps Script error
Exception: You are trying to edit a protected cell or object. Please contact the spreadsheet owner to remove protection if you need to edit.
What it means
Google Sheets enforces sheet and range protections against the account executing the script (Session.getEffectiveUser()). A simple onEdit(e) trigger or custom menu runs as the person at the keyboard, so writing to a protected audit column fails for restricted editors. Action not allowed appears for similar permission blocks, such as trying to write to a view-only file or rename a locked tab.
Related error messages
- Exception: Action not allowed
- Exception: You do not have permission to perform that action.
Before and after
The code before and after the fix.
// Simple onEdit(e) runs as the person editing the sheet.
// If that editor is blocked by a protected range, writing to the audit column fails.
function onEdit(e) {
if (!e || !e.range) return;
const sheet = e.range.getSheet();
sheet.getRange(e.range.getRow(), 6).setValue(new Date());
}// Rename the function and install an "On edit" trigger as the spreadsheet owner
// (or an account allowed to edit the protected range).
/** @param {Events.SheetsOnEdit} e */
function stampProtectedAuditColumn(e) {
if (!e || !e.range) return;
const sheet = e.range.getSheet();
if (sheet.getName() !== 'Requests') return;
sheet.getRange(e.range.getRow(), 6).setValue(new Date());
}How to fix it
- To let restricted editors trigger writes to a protected column, rename the function away from onEdit and create an installable "On edit" trigger under an account that is allowed to edit the protected range.
- Check Data > Protect sheets and ranges in Google Sheets and verify the executing account is listed under "Who can edit this range".
- Verify the executing account has Editor (not Viewer or Commenter) sharing access on the spreadsheet itself.
Things to check
- Warning-only protections prompt humans in the UI, but Apps Script edits can bypass warning-only protections; hard editor-list protections block scripts run by unlisted accounts.
- Because an installable trigger runs with the trigger owner permissions, validate the target sheet and range carefully before writing.
In the Apps Script editor
Catch errors like this before clicking Run.
myFunction (published as Error Checker for Google Apps Script on the Chrome Web Store) checks your code while you edit at script.google.com. Diagnostics, autocomplete, and rule-based quick fixes are free without an account, run in your browser, and request no Google Drive, Gmail, or Apps Script project OAuth scopes. Writing Apps Script with an AI coding agent? Connect the Apps Script MCP server to run the same static checks before pasting code.