title: CopyTo in Sheets Stops Working without Error
body: <p><strong>Edit:</strong> Apologies for the confusion. This has been solved and is not related to the code below. There was a &quot;clear bulksheet&quot; function that deleted values up to 900 rows. Unfortunately, what happened was that the first script went beyond those 900 rows and so while it appeared everything was deleted it was not. So the function went down and started copy/pasting after all the data remaining past 900. I scrolled a few hundred rows but not all the way. Turns out it was working the whole time, I just couldn't see it :D</p>
  <hr />
  <p>I have a Google Apps Script that loops through a column, sets a value to a template (in a separate sheet) and then copy/pastes that template to the first empty row in another sheet. All sheets are in the same workbook as separate tabs.</p>
  <p>The function works fine the first time and is replicated identically across several different &quot;Templates&quot; where it still functions. I've duplicated the sheet (which duplicates the code) and it still doesn't work.
  The only work around I've found is to create an entirely new sheet and put the code into it.</p>
  <p>The first function copies the template to the bulksheet.</p>
  <p>The second function loops through a column with x rows of text. Grabs the value of text from the column and pastes to the template from the column and sets the value in the template. Then it calls the first function.</p>
  <p>I've confirmed that the second function is looping through and setting the values in the template so the function appears to be running but the template never ends up being pasted.</p>
  <p>This seems to happen randomly so I'm not sure if it's a bug or a caching issue. I successfully ran the script the first time to set/copy/paste over 100 times. Then it broke.</p>
  <p>I've tried to flush but I'm not sure if I'm doing that correctly in terms of where to put it (I've tried a few spots). I've changed out var and let to see if that was an issue.</p>
  <p>Again, no errors are thrown and the function runs to completion.</p>
  <p>Appreciate any help!</p>
  <pre><code>function CopyTemplateToBulkSheet() {
    
    let ss = SpreadsheetApp.getActiveSpreadsheet();
  
    let templateSheet = ss.getSheetByName('Template-make a copy');
    let copyRange = templateSheet.getRange('A2:U7')
    
    let BulkSheet = ss.getSheetByName('BulkSheet');
    let pasteRange = BulkSheet.getRange(BulkSheet.getLastRow()+1, 1);
  
    copyRange.copyTo(pasteRange, {contentsOnly:true});
  }
  
  
  function Loopthrough(){
  
    Logger.log('Beginning Campaign Creation')
    let ss = SpreadsheetApp.getActiveSpreadsheet();
  
    let templateSheet = ss.getSheetByName('Template-make a copy')
  
    let keywordrange = ss.getRange('H3:H').getValues();
    let targetkeywords = keywordrange.filter(String);
  
    targetkeywords.forEach(function(value){
      templateSheet.getRange('L5').setValue(value)
      CopyTemplateToBulkSheet();
  })
  }
  </code></pre>