title: You do not have permission to use copyTo
body: <p>I'm trying to copy a range from one sheet to another (<strong>whilst preserving the formulas</strong>). I wrote a simple script using <code>copyTo</code>:</p>
  
  <pre><code>function copyRangeAcrossSheets(source_sheet,source_range,target_sheet,target_range) {
    var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
    var source_sheet = spreadsheet.getSheetByName(source_sheet);
    var target_sheet = spreadsheet.getSheetByName(target_sheet);
    var source_range = source_sheet.getRange(source_range);
    var target_range = target_sheet.getRange(target_range);
    source_range.copyTo(target_range);
  }
  </code></pre>
  
  <p>Which I call as followed:</p>
  
  <p><code>=copyRangeAcrossSheets("TEST_source","A1:A3","TEST_target","A1:A3")</code></p>
  
  <p>And I'm getting the below error:</p>
  
  <blockquote>
    <p>You do not have the permission to call copyTo</p>
  </blockquote>
  
  <p>I did some digging around and found that <a href="https://stackoverflow.com/questions/27744929/google-script-openbyid-you-do-not-have-permission-to-perform-that-action">functions have to use special triggers (installable) in order to modify another file</a>. However here I'm modifying the same file.</p>
  
  <p><strong>Q1: Why is <code>copyTo</code> failing here?</strong>  </p>
  
  <p><strong>Q2: How can I workaround the issue without having to define installable triggers?</strong> (I just want to copy ranges whilst preserving formulas)</p>