Google apps script to find a string and change the column background color -
i have results of google form (a google spreadsheet). write app script check each column string "yes." if column has string, change background color of column (or 1 cell in column) green. number of columns vary each time form sent need check columns used (sorry, mean send out similar form each time , want use same script on each one, except each time form used can come different number of columns-responses - corn3lius). can done in google form response spreadsheet? here code playing with. (updated code cooper's input)
function colchk(){ var ss = spreadsheetapp.getactivesheet(); var resp = ss.getdatarange().getvalues(); for(var n=0;n<resp.length;n++) { for(var p=0;p<resp[n].length;p++) { if(resp[n][p].tostring().match(/^yes/)){ ss.getrange(n+1,p+1).setbackground('#00ff00')}}}; } //this code works...thanks cooper!
try this:
if(resp[n][0].tostring().match(/^yes/){ ss.getrange(n+1,1).setbackground('#00ff00') };
perhap's this:
function colchk(){ var ss = spreadsheetapp.getactivesheet(); var resp = ss.getdatarange().getvalues(); for(var n=0;n<resp.length;++n) { for(var p=0;p<resp[n].length;p++) { if(resp[n][p].tostring().match(/^yes/){ ss.getrange(n+1,p+1).setbackground('#00ff00') }; } };
Comments
Post a Comment