I am writing a custom function in sheets that will not have a defined number or format of arguments. As an example, the call might be: =myFunc(a1:b3,a2:a4,b1:b9,c1,d2, [might be more, might be less])
I want to step through every value sent in and operate on it but run into all kinds of problems (mostly my own I am sure). I seem to run into problems distiguishing between a 2D and 1D set of inputs. Conceptually, I was thinking of something like this(not my actual code).
function myFunc(values) {
var i;
var calcVal = 0;
for (var j= 0; j < values.count; j++) {
if (values[j] > 1) {
calcVal = calcVal + values[j]*j;
}
}
return calcVal;
Is there some straightforward way of walking through each value coming in one at a time?