title: How to make seacrhFunction appear for the last row (from bottom/latest entry) in Apps Script
body: <p>I'm working on Data entry automation in Google Sheet + Apps Script.
  In  my project, there will be multiple entries with same details, only few column will be different.</p>
  <p>And I'm having issue with the search function where the data is reflect from top row.
  In this project, the latest entry will indicates latest status/task</p>
  <pre><code>function searchRecord(){
    
    var myGoogleSheet=SpreadsheetApp.getActiveSpreadsheet();  
  
    var shUserForm=myGoogleSheet.getSheetByName(&quot;Tracker&quot;); 
  
    var datasheet=myGoogleSheet.getSheetByName(&quot;GF&quot;);
  
    var str=shUserForm.getRange(&quot;E4&quot;).getValue();
    var str=shUserForm.getRange(&quot;E6&quot;).getValue();
    
    var values=datasheet.getDataRange().getValues(); 
    
    var valuesFound=false; 
  
    //store boolean value
    
    for (var i=0; i&lt;values.length; i++) 
      {
  
      //storing the value
      var rowValue=values[i]; 
     
      //checking the first value of the record is equal to search item
      if (rowValue[6,14]==str){
  
        shUserForm.getRange(&quot;E11&quot;).setValue(rowValue[2]);
        shUserForm.getRange(&quot;E13&quot;).setValue(rowValue[3]);
        shUserForm.getRange(&quot;E15&quot;).setValue(rowValue[4]);
        shUserForm.getRange(&quot;E17&quot;).setValue(rowValue[5]);
        shUserForm.getRange(&quot;E19&quot;).setValue(rowValue[6]);
        shUserForm.getRange(&quot;E21&quot;).setValue(rowValue[9]);
        shUserForm.getRange(&quot;E23&quot;).setValue(rowValue[15]);
        shUserForm.getRange(&quot;E25&quot;).setValue(rowValue[16]);
        shUserForm.getRange(&quot;E27&quot;).setValue(rowValue[18]);
        shUserForm.getRange(&quot;E29&quot;).setValue(rowValue[27]);
        shUserForm.getRange(&quot;E31&quot;).setValue(rowValue[14]);
        shUserForm.getRange(&quot;E33&quot;).setValue(rowValue[28]);
        shUserForm.getRange(&quot;E35&quot;).setValue(rowValue[29]);
        valuesFound=true;
        return; //come out from the loop
        
        }
    }
  
  if(valuesFound==false){
  
    //alert function
  
    var ui=SpreadsheetApp.getUi();
  
    ui.alert(&quot;Enter correct details&quot;);
   }
  
  }
  </code></pre>