0
votes

Getting error "The action you're trying to perform is causing a fatal error and cannot be performed" on this line-

sheet.getRange(m, k, enD, 1).setValues(sheet.getRange(m, k, enD, 1).getValues());

My code has been running without errors for a week but since yesterday I am getting this error randomly. Sometime it works sometime it doesn't. I don't wish to disclose the calculations and that's why I am using this.

Any idea why this is happening? I tried reducing 'enD' values from 40s to 10s or 20s. Doesn't help. Tried splitting the code - read values using getValues() first and then write using setValues but again getting error on getValues() part.

1
As an electronics engineer the line you describe is what is called a loop...can you explain what it can be used for? Have you tried to use an array as an intermediate variable? - Serge insas
Like I mentioned I am trying to replace the formulas in the cells by their values like we do in excel, copy then pastevalues only. I have tried storing values in an array first and then write it to the cells but the reading 'getValues()' part gives me the same error. - user2038613
what is the exact error message?what values are you passing for Ranger arguments? - ScampMichael

1 Answers

1
votes

I tried this simple test script to check how it could work and I get this log :

3.141592653589793  =PI()
3.14159265358979  

The script goes like this :

function replaceFormulasByValues() {
  var ss = SpreadsheetApp.getActiveSheet();
  var sel = ss.getActiveRange();
  Logger.log(sel.getValues()+'  '+sel.getFormulas()); // show cell's content (value and formula) 
  sel.setValues(sel.getValues());// this is the same mechanism you use
  Logger.log(sel.getValues()+'  '+sel.getFormulas()); // no formulas anymore
}

So it works as expected doesn't it ?