Column A :
Number |
---|
1 |
2 |
... |
31 |
Hello,
Actually I'm looking for a mean to add empty row under conditions with a short running time on Google Apps Script. So I first tried to test a very simple example :
function insertRow(){
var ss = SpreadsheetApp.getActive();
var sh = ss.getSheets()[5];
var temp = sh.getRange("A1:A"+sh.getRange("A1").getDataRegion().getLastRow()).getValues();
Logger.log("Temp : " + temp);
i = 0;
while (i < temp.length && temp[i][0] != ""){
if(temp[i][0] == 20){
var old1 = temp.slice(0,i);
var old2 = temp.slice(i);
Logger.log("Old1 : " + old1+"\nOld2 : " +old2);
old1.push([""]);
temp = old1.concat(old2);
Logger.log(temp);
}
i++;
}
}
But it adds me infinite row in my array and I'm blowing my minds to understand.
At the end, to make my script working,
I have to put sh.getRange(1,1,temp.length,temp[0].length).setValues(temp);
I want to use setValues() Format because making work this if statement cell by cell could take a very long time if there is too much data.
Can you please, help me on this ?