script to enter formula

1

Well, I've booted a script to check if a column contains a formula, and if it does not contain it, it inserts it. I'm doing this because every time I fill out a form, the formula that was before in the cell disappears. Soon, the script will run every hour, check if the formula has been deleted and, if so, it inserts it again. Well, me script and this? However, it is not working, although it does not acknowledge any errors, the formula does not appear in the column as it should. NOTE: If I put the double quotation marks, it gives an error of: ~ Missing; before the declaration. (line 13, file "insereFormula"). Line 13 and this: term="= IF (COUNTA (E4) = 0;" "; E4-TODAY ())";       So, I just left single quotes.

function myFunction() {

  var sheet = SpreadsheetApp.getActiveSheet();
  var startRow = 0;  // First row of data to process
  var numRows = sheet.getLastRow();
  var lastCol = sheet.getLastColumn();
  var dataRange = sheet.getRange(2, 1, numRows-startRow,lastCol).getValues();  //Get all values except the header rows


  for (var i=0;i<numRows-startRow;i++){ 
  var prazo = dataRange[i][8];
    if (prazo == '') {
     prazo = '=IF(COUNTA(E4)=0;"";E4-TODAY())'; 

    }
  }
}
    
asked by anonymous 19.05.2018 / 23:35

0 answers