I have a column of cells. Some of the cells have data, and some of the cells are blank. How do I allow users to edit the cells with data but restrict entry to the blank cells?
Searched previous posts and have not found answer
To prevent users from editing a sheet except certain cells, choose Data > Protected sheets and ranges > Add > Sheet > ✅ Except certain cells.
See Protect a range or sheet.
If you do not want to list the cells that are OK to edit, you could try writing a script to detect edits, but there will be many limitations. Here’s some sample code to get you started:
/**
* Simple trigger that runs each time the user manually edits the spreadsheet.
*
* @param {Object} e The onEdit() event object.
*/
function onEdit(e) {
if (e && e.value && !e.oldValue) e.range.setValue(null);
}
That will only work for single-cell edits, and will probably not work the way you expect for copy and paste, where the event parameter e
does not include the required information.
See simple triggers.