title: Google Apps Script Fastest way to find a row?
body: <p>I am trying to find out what the fastest way is to get some data from a row where a value matches my query, I am currently using this code:</p>
  
  <pre><code>var spr = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('CustomerList'); 
    var klantNummer = array1[0].toString();
    var emailgebruiker = Session.getActiveUser().getEmail();      
    var data = spr.getDataRange().getValues(); 
    for(n=0;n&lt;data.length;++n){ 
      if(data[n][0].toString() == klantNummer){ //.match(klantNummer)
        data[n][21] = emailgebruiker
  
     var KlantNR = data[n][0];
     var Email = data[n][3];
     var Stad = data[n][12];          
     var Taalschool = firstToUpperCase( data[n][13].toString() );    
     var Cursus = firstToUpperCase( data[n][14].toString() );      
     var Weken = data[n][15];
     var Accommodatie1 = data[n][17];
     var TypeAccommodatie = data[n][18];
     var TypeKamer = data[n][19];
     var VertrekDatum1 = data[n][20];
  
      };
    }
    spr.getRange(1,1,data.length,data[0].length).setValues(data); 
  </code></pre>
  
  <p>It works fine when I use it in a small sheet but when the sheet gets bigger it starts to become slow, is there a better way to do this?</p>