so I am trying to make my code work. It does... sometimes.
The code is:
function getAntallVakter(tabell, navn) {
var antall = 0;
for(i = 0; i<tabell.length;i++){
for(j=0;j<tabell[i].length;j++){
if(tabell[i][j].indexOf(navn)>-1){
antall += 1;
}
}
}
return antall;
}
It does work when I tested it, but when I used it on the spreadsheet that needs this script it doesn't work for the given range. It does work on other ranges. On the specific ranges it doesn't work I got some of these error:
TypeError Cannot find function indexOf in object 0 (Line 7 in Code.gs)
TypeError Cannot find function indexOf in Thu Jan 01 2015 00:00:00 GMT+0100 (CET).
I appreciate any help I get.
I can't belive I totally forgot to check weather the cells are strings or not.
adding the line
var text = tabell[i][j].toString();
before the if-sentence fixed everything.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With