Copy row by row if value of cell is correct (by using Google Script) -
i'm trying create google script copies rows 1 google sheet same sheet different column based on value of cell. here's example:
b c d e f
1| john 12 open
2| nick 31 closed
3| sara 12 open
4| dany 32 closed
..n| nick 221 open
if cell in column c "closed", need copy columns a,b,c d,e,f. if cell in column c "open" ignore , not copy a,b,c d,e,f.i know, can use normal function "if", need use google script because need have in columns d,e,f pure text or value (without formulas). thank in advance help.
okay removed global set values , replace updating columns d,e,f when closed. run little slower shouldn't messing formulas.
function copyifclosed() { var ss=spreadsheetapp.getactive(); var sht=ss.getsheetbyname('example'); var lastrow=sht.getlastrow(); var rng=sht.getrange(1,1,lastrow,6); var rnga=rng.getvalues(); for(var i=0;i<rnga.length;i++) { if(rnga[i][2]=='closed') { sht.getrange(i+1,4).setvalue(rnga[i][0]); sht.getrange(i+1,5).setvalue(rnga[i][1]); sht.getrange(i+1,6).setvalue(rnga[i][2]); } } spreadsheetapp.flush(); }
hope helps.
here's sheet looks like:
Comments
Post a Comment