title: How to define range that could vary in google apps script
body: <p>I'm trying to make a copy of one spreadsheet using a (time driven) Google App Script. I found a very useful piece of code here, but my concern is that the range varies frequently (new rows are added). How can I copy the entire spreadsheet no matter if the range changes?. because as you can see in the code below I have defined the range, but when this changes the information out of the defined range will be discarded. What can I do?
  Thanks in advance. </p>
  
  <p>Here the code I'm using:</p>
  
  <pre><code>    function saveAsSpreadsheet(){ 
        var timestamp = new Date();
        var sheet = SpreadsheetApp.getActiveSpreadsheet();
        var range = sheet.getRange('sheetName!A1:AO158');
        sheet.setNamedRange('sheetName', range);
        var TestRange = sheet.getRangeByName('sheetName').getValues(); 
        Logger.log(TestRange); 
        var destFolder = DriveApp.getFolderById("folderID"); 
        DriveApp.getFileById(sheet.getId()).makeCopy("FileName:"+ timestamp, destFolder); 
      }
  </code></pre>