title: How to import data from another Google Sheet using Google Script without using Spreadsheet ID
body: <p>I have a Google Script that imports my data range from one Google Sheet to another Google Sheet and it works perfectly.</p>
  
  <p>My issue is however the original data sheet gets updated daily by a third party (CloudHQ) which replaces the original version, this means that a new spreadsheet ID is created which renders this script incorrect daily.</p>
  
  <p>Is there a way to import a data range by another google script method by using something constant such as the file name or file location?</p>
  
  <p>Please find my code below:</p>
  
  <pre><code>    var sourceSpreadsheetID = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
      var sourceWorksheetName = "CustomSheetName1";
      var targetSpreadsheetID = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
      var targetWorksheetName = "Sheet1";
  
  function importData1() {
    var thisSpreadsheet = SpreadsheetApp.openById(sourceSpreadsheetID);
    var thisWorksheet = thisSpreadsheet.getSheetByName(sourceWorksheetName);
    //var thisData = thisWorksheet.getDataRange();
    var thisData = thisSpreadsheet.getRangeByName("B:B");
  
    var toSpreadsheet = SpreadsheetApp.openById(targetSpreadsheetID);
    var toWorksheet = toSpreadsheet.getSheetByName(targetWorksheetName);
    var toRange = toWorksheet.getRange(1, 1, thisData.getNumRows(), thisData.getNumColumns())
    toRange.setValues(thisData.getValues()); 
  }
  </code></pre>