title: Google Spreadsheets script, copyTo vs copyValuesToRanges & copyFormatsToRanges
body: <p>I need to copy a template row to a new range.</p>
  <p>The template cell have contents where format, values and functions may be present.</p>
  <p>As I was copying one row to a range of multiple rows, the functions copyValuesToRange() and copyFormatsToRange() looked good.</p>
  <p>Essentially my code went a bit like this;</p>
  <pre><code>Template.copyFormatToRange(sheet, 1, lastColumn, lastRow + 1, lastRow + N);
  Template.copyValuesToRange(sheet, 1, lastColumn, lastRow + 1, lastRow + N);
  </code></pre>
  <p>This copies my template row over N new rows starting at lastRow+1.</p>
  <p>Then I noticed it was not copying the functions in the template row, e.g. =SUM(B2:C2)</p>
  <p>I can getFunctions() to get an array that contains the functions in my template row and setFunctions() to copy them into a target ROW.
  An inconvenience is that I have to switch to A1 notation, which adds execution time to the script. Importantly the target range that setFunctions() writes to must be the same size as the array. This means I have to run a for loop to copy the functions over N rows.</p>
  <p>If I am running a for loop anyway I can just use</p>
  <ul>
  <li><p>for loop copyTo()</p>
  <p>instead of</p>
  </li>
  <li><p>copyFormatToRange</p>
  </li>
  <li><p>copyValuesToRange</p>
  </li>
  <li><p>for loop to setFunctions</p>
  </li>
  </ul>
  <p>I was trying to avoid using copyTo() because I figured for N of certain size the single commands copy*****ToRange would be more efficient that a for loop.  Am I stuck with the for loop or is there any clever way I can copy the functions form a singe row to a range of rows?</p>