title: getSheetByName google apps Script returns null
body: <p>I'm stuck and can't find an answer for my problem. </p>
  
  <p>Here's my current code:</p>
  
  <pre><code>var monthSheet = sourcesheet.getRange('A1').getValue();
  var destsheet = shoot.getSheetByName(monthSheet);
  </code></pre>
  
  <p>monthSheet is String<br>
  destsheet is always <strong>null</strong> and I don't know why...</p>
  
  <p>edit:</p>
  
  <pre><code>function sendAnnouncement() {
  
  
  
   var files = DriveApp.getFolderById("xxxxxxxxxxxxxxxxx").getFiles()
      while (files.hasNext()) {
        var file = files.next();
        var shoot = SpreadsheetApp.openById(file.getId());
  
  
    var sourcesheet = SpreadsheetApp.getActive().getSheetByName("Announcements");
    var sourceAnn = sourcesheet.getRange('B2:B2').getValue();
  
    var sourceMonth = sourcesheet.getRange('A2').getValue();
    sourcesheet.getRange('A1').setFormula("=VLOOKUP(A2;Settings!B1:C12;2;false)");
    var monthSheet = sourcesheet.getRange('A1').getValue();
    var sourceTaxStake = sourcesheet.getRange('C2').getValue();
  
  
   var destsheet = shoot.getSheetByName(monthSheet);
   var destTaxStake = destsheet.getRange('H2').getValues();  
  
    if ('sourceTaxStake' == "all")
    {
  var destrange = destsheet.getRange('D8:D8'); 
  destrange.setValues(sourceAnn);     
  }
    else if ('destTaxStake' == 'sourceTaxStake')
    {
  var destrange = destsheet.getRange('D8:D8'); 
  destrange.setValues(sourceAnn);     
  }
  else    
  {
  }
  </code></pre>
  
  <p>}
  }</p>