spreadsheet - Google Docs make custom function refresh -
so have 1 code takes range , reference cell, , returns number of cells same background color ref. works great, want usable when color of of cells changes. put on every minute time based trigger, , tried use spreadsheetapp.flush()
uncache current number. did not have desired affect.
i tried make second function used flush() , returned first function. did not work. way know make refresh take "=
" beginning of cell function in it, , replace it. code works below.
function countbgcolor(range, ref) { var sheet = spreadsheetapp.getactivesheet(); var color = sheet.getrange(ref).getbackground(); var range = sheet.getrange(range); var rangeval = range.getvalues(); var count = 0; var allcolors = range.getbackgrounds(); (var = 0; < allcolors.length; i++) { (var j = 0; j < allcolors[0].length; j++) { if (allcolors[i][j] == color) count += 1; }; }; return count; }
i couldn't find direct way this. make script clears formula , reenters cell:
function refresh() { var sheet = spreadsheetapp.getactivesheet(); var range = sheet.getrange('d1'); range.clear(); spreadsheetapp.flush(); range.setformula('=countbgcolor("a1:a10","e1")'); }
next link image script's function: insert > image >
in top right menu of image, assign script
Comments
Post a Comment