I have a concat_custom
script I'd like to execute 10 rows at a time.
For example, in this sheet:
Custom function:
function concat_custom(s, array) {
array = conformToOneDimensionalArray(array);
return array.filter(function (value) {
return value != "";
}).join("-");
}
function conformToOneDimensionalArray(value) {
if (!Array.isArray(value)) {
value = [value];
}
else if (Array.isArray(value[0])) {
value = value.reduce(function(a, b) {
return a.concat(b);
});
}
return value;
}
I'd like column C to have text Ted-John
and not =concat_custom("-",A1:B1)
so column C will be independent of A & B
. How can I process say 10 rows at a time in this example?
I'd like to be able to process 10 rows every minute through timed triggers. So it checks the last row then continues from there.
Try this:
function withadash() {
var ss=SpreadsheetApp.getActive();
var sh=ss.getActiveSheet();
var nextrow=getNextRowInColumn3();
if(nextrow>0) {
var rg=sh.getRange(nextrow,1,10,3);
var vA=rg.getValues()
for(var i=0;i<vA.length;i++) {
vA[i][2]=vA[i][0]+'-'+vA[i][1];
}
rg.setValues(vA);
}
}
function getNextRowInColumn3() {
var ss=SpreadsheetApp.getActive();
var sh=ss.getActiveSheet();
var rg=sh.getRange(1,3,sh.getLastRow(),1);
var vA=rg.getValues();
for(var i=0;i<vA.length;i++) {
if(!vA[i][0]) {
return i+1;
}
}
return 0;
}