title: Google Spreadsheet: TypeError Cannot find function indexOf in object 0 (Line 7 in Code.gs)
body: <p>so I am trying to make my code work. It does... sometimes. </p>
  
  <p>The code is:</p>
  
  <pre><code>function getAntallVakter(tabell, navn) {
  
    var antall = 0;
  
    for(i = 0; i&lt;tabell.length;i++){
      for(j=0;j&lt;tabell[i].length;j++){
        if(tabell[i][j].indexOf(navn)&gt;-1){
          antall += 1;
        }
      }
    }
    return antall;
  }
  </code></pre>
  
  <p>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:</p>
  
  <p>TypeError Cannot find function indexOf in object 0 (Line 7 in Code.gs)<br>
  TypeError Cannot find function indexOf in Thu Jan 01 2015 00:00:00 GMT+0100 (CET). </p>
  
  <p>I appreciate any help I get. </p>