title: How much faster could I make this script?
body: <p>I have noticed that the script is significantly faster when I comment out the line that calls <code>setValues()</code>. Not that it's a super big issue, but I am interested in the different ways (if any) that I could speed the process up. If anyone has some insight, I would greatly appreciate it! It would also help me see where I could make similar optimizations in other parts of my script.</p>
  <p>Here is the code in question:</p>
  <pre><code>// import new value(s)
    if ((numRaw - numDk) &gt; 0) {
      var iDate;
      var lastRow = getLastDataRow(earSheet, columnToLetter(earSheet.getRange(&quot;EAR_DATES_RNG&quot;).getColumn()));
      var distName = impSheet.getRange(&quot;A1&quot;).getValue().toString();
      var defaultDept = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(&quot;All Lists&quot;).getRange(&quot;A2&quot;).getValue().toString();
  
      impData.forEach(function (entry) {
        iDate = new Date(entry[0]);
        var newEar = earSheet.getRange(&quot;A&quot; + lastRow + &quot;:G&quot; + lastRow).getValues(); // init copy
  
        if (currData.get(iDate.getTime()) == null) {
          newEar[0][0] = entry[0];
          newEar[0][1] = distName;
          newEar[0][6] = entry[1];
  
          newEar[0][3] = &quot;Royalties&quot;;
          newEar[0][4] = defaultDept;
          newEar[0][5] = &quot;NOT SPECIFIED&quot;;
  
  
          earSheet.getRange(&quot;A&quot; + lastRow + &quot;:G&quot; + lastRow).setValues(newEar);
  
          Logger.log(&quot;ADDED: &quot; + entry[1] + &quot; to row: &quot; + lastRow);
          addedNewData++;
          lastRow++;
        }
        else {
          Logger.log(&quot;EXISTING DATA FOUND: &quot; + currData.get(iDate.getTime()));
        }
      });
    }
  </code></pre>