I have some frozen rows but other users (who must have edit permissions) are inadvertently unfreezing them. I have tried adding protection to the rows so they cannot edit them, but they can still unfreeze them. Is there any workaround for this?


1 Answer 1


One duct tape fix would be use an onEdit(e) simple trigger to reset row freezing every time the spreadsheet is hand edited, like this:

function onEdit(e) {
  if (!e) {
    throw new Error('Please do not run the script in the script editor window. '
      + ' It runs automatically when you hand edit the spreadsheet.');
  const enforce = [
      sheetName: /^(Sheet1|Sheet2|Sheet3)$/i,
      frozenRows: 1,
  const sheet = e.range.getSheet();
  const sheetName = sheet.getName();
  enforce.some(enforce => {
    if (sheetName.match(enforce.sheetName)
      && sheet.getFrozenRows() !== enforce.frozenRows) {

This function will not do anything when the user unfreezes rows, but it will automatically re-freeze rows when the user next modifies a value in any cell in the sheet.

You can choose how many rows to freeze in each sheet by inserting more { objects } in the enforce array. Sheets are matched using regular expressions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.