title: My Google App Script takes too long to end. Need to do it faster
body: <p><strong>Issue:-</strong> My script usually takes 5 minutes on an average. Can we change anything in the code to transfer the data quicker?</p>
  <p><strong>What it does?</strong></p>
  <ul>
  <li>It transfers the fresh data populated in the source sheet into the repository in the destination sheet. The source sheet data is refreshed every day, but in the destination sheet, data transferred gets appended day by day.</li>
  </ul>
  <p><em><strong>Here is the script:</strong></em></p>
  <pre><code>function UploadRepository() { 
    var sheet1 = SpreadsheetApp.openById(&quot;SourceSheet&quot;); 
    var sheet2 = SpreadsheetApp.openById(&quot;DestinationSheet&quot;); 
    var currDate = new Date(); 
    var editedDate = new Date(currDate - 86400000); 
    var insert = sheet1.getSheetByName(&quot;SourceSheetName&quot;); 
    var archive = sheet2.getSheetByName(&quot;DestinationSheetName&quot;); 
    var insertData = insert.getRange(2, 1, (sheet1.getRange('A:A').getNextDataCell(SpreadsheetApp.Direction.DOWN).getRow()), 28); 
    for (row = 2; row &lt;= insertData.getNumRows(); row++) { 
      var data = insert.getRange(row, 1, 1, 28).getValues(); 
      if (data[0][0] &lt; currDate &amp;&amp; data[0][0] &gt; editedDate) { 
        archive.getRange((archive.getLastRow() + 1), 1, 1, 28).setValues(data).setNumberFormat(&quot;MM/dd/yyyy&quot;); 
      } 
    }
  }
  </code></pre>