0
votes

I'm working on a google apps script project where the script locks a header row so users can't change it. However, this prevents users from changing any column widths, since that entails editing the protected range. I want to be able to keep users from editing content in the header row, but allow them to resize columns.

Before this can be scripted, I can't seem to figure out how this would work with the base Google sheets functionality. Is it possible? Either by protecting individual cells, protecting a sheet minus a range, or protecting a range?

1

1 Answers

2
votes
function onEdit(e) {
  const sh = e.range.getSheet();
  const hr = [['Col1','Col2'....]];//Edit this line with the column headers
  if( e.range.rowStart == 1) {
    sh.getRange(1,1,1,sh.getLastColumn()).setValues(hr);
  }
}