title: Why would setFormula() turn a working formula into one with #REF
body: <p>My situation is that I have entered a formula in my google sheet and it works correctly.  I am putting that exact formula in as a setFormula() but when I refresh the document, it replaces cell references with <code>#REF!</code>.</p>
  
  <p>I have checked to make sure single or double quotes are not interfering with the formula.  My formula does reference another tab but putting single quotes around the Tab name has no effect either.  I have also visited these posts but none answer the question.</p>
  
  <p><a href="https://stackoverflow.com/questions/53835376/ref-being-added-to-formula-by-setformula-instead-of-an-actual-reference-if">#REF! being added to formula by setFormula() instead of an actual reference: IF(NOT(ISBLANK(N3)),#REF!,0))</a></p>
  
  <p><a href="https://stackoverflow.com/questions/54034452/getformulas-and-setformulas-convert-references-to-ref">getFormulas() and setFormulas() convert references to #REF</a></p>
  
  <p>My Code is as follows...</p>
  
  <pre><code>function setFormulas(){
  
    var setup = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Set Up");
    var c1id = setup.getRange("J2").clearContent().setFormula("=index(\'MRTool\'!B1:B39,Match(D2,'\MRTool'\!A1:A39,0))");
  </code></pre>
  
  <p>I expect the formula in cell J2 to look like this:
  <code>=index(MRTool!B1:B39,Match(D2,MRTool!A1:A39,0))</code></p>
  
  <p>What I see is this:
  <code>=index(#REF!,Match(#REF!,#REF!,0))</code></p>