Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>From reading your code it seems that you're trying to do a different thing from what you've explained. I see that you trying to "repair" the formulas. But why <code>if (CellColumn == 2 )</code>? You want to protect only column <code>B</code>, not the whole "master" sheet?</p> <p>Can you share a sample spreadsheet of what your sheet structure looks like?</p> <p>Anyway, I'll suppose that you want to warn when you overwrite anything on your "master" sheet, auto-repairing the formula is a little more complicated (depending on your scenario), and after reading the popup it's easy to just hit undo and recover it. But you really mean to auto-repair the formulas, I'll enhance my code after you share a sample of your spreadsheet, since it's a slightly complicated and depends highly on your structure.</p> <pre class="lang-js prettyprint-override"><code>function onEdit() { var s = SpreadsheetApp.getActiveSheet(); if( s.getName() == "Master" ) Browser.msgBox("DON'T MESS WITH THE FORMULAS!"); } </code></pre> <p>If you're doing simple reference formulas on other sheets it's somewhat easier and probably a good solution for you to use an ArrayFormula, that will auto-replace back the value when you change any cell, except for the first cell, but then a manual undo will be so rare and obvious that it will not be an issue, I think. I did an example of array formula on the spreadsheet you linked, please take a look. On <code>A1</code> I wrote:</p> <pre><code>=ArrayFormula(Sheet1!A1:F20) </code></pre> <p>Now, if you go and accidentally writes something on <code>B2</code> for example, it value will automatically come back. Try and see if that's a good solution for you. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload