google apps script - GAS Split one cell and fill down another -
i have following situation:
column g column h |black, brown, grey| | dog | |calico | | cat | |green, blue | | bird| | ... | | ... |
i split , fill down this:
column g column h |black | |dog | |brown | |dog | |grey | |dog | |calico| |cat | |green | |bird| |blue | |bird| |... | | ...|
looking @ script split comma delineated cell (function split text in cell , create column) can follow split it's filling down portion having trouble with. understand should set while
loop first cell var = , second cell var = j. dump split contents of array , fill down array.length. however, can't seem syntax correct.
i'm pretty new js , gas appreciated.
thanks help.
-jh
here's custom function should work you:
/** * splits array commas in column given index, given delimiter * @param {a2:b20} range range reference * @param {2} coltosplit column index * @param {","} delimiter character split * @customfunction */ function advancedsplit(range, coltosplit, delimiter) { var resarr = [], row; range.foreach(function (r) { r[coltosplit-1].replace(/(?:\r\n|\r|\n)(\d|\w)/g,", ").split(delimiter) .foreach(function (s) { row = []; r.foreach(function (c, k) { row.push( (k === coltosplit-1) ? s.trim() : c); }) resarr.push(row); }) }) return resarr.filter(function (r) { return r.tostring() .replace(/,/g, "") }) }
this function can used this:
Comments
Post a Comment