google apps script - How can I put the formula only in the last 20 rows of this range? -
i want code works in last 20 rows of sheet. sets formula in of blanks cells of column want code in 20 last rows.
function setformulainblankcells() { //----------------- colonna --------------- // formula solo su celle vuote "area" var sheet=spreadsheetapp.getactivesheet(); var lastrow=sheet.getmaxrows(); var lastcolumn=sheet.getmaxcolumns(); var range=sheet.getrange(1, 1, lastrow, 1); var data=range.getvalues(); for(var i=0;i<data.length;i++) { if(!data[i][0]) { var e1=sheet.getrange(i+1,5).geta1notation(); var i1=sheet.getrange(i+1,9).geta1notation(); var formula='=iferror(if(' + e1 + '="";"";if(' + i1 + '="";"ru";"st")))' sheet.getrange(i+1,1).setformula(formula); } }
}
i guess meant in last 20 rows of sheet
function setformulainblankcells() { var sheet=spreadsheetapp.getactivesheet(); var lastrow=sheet.getmaxrows(); var range=sheet.getrange(1, 1, lastrow, 1); var data=range.getvalues(); for(var i=data.length-20;i<data.length;i++) { if(!data[i][0]) { var e1=sheet.getrange(i+1,5).geta1notation(); var i1=sheet.getrange(i+1,9).geta1notation(); var formula='=iferror(if(' + e1 + '="";"";if(' + i1 + '="";"ru";"st")))' sheet.getrange(i+1,1).setformula(formula); } } }
Comments
Post a Comment