title: Google spreadsheet - #N/A error when imported range has a custom function
body: <p>In my Google spreadsheet (<em>the newest version, as of August 2014</em>) I'm using <code>=IMPORTRANGE(P5,"Tasks!b6:o7")</code> where <code>P5</code> cell contains another spreadhsheet's key. One of the cells in the other spreadsheet contains my custom function, that sometimes takes time to calculate (there are dozens of cells using that function). The problem is that in the first spr. that cell's value is not displayed properly, the <code>#N/A</code> error message is displayed instead.</p>
  
  <p>The function is defined as follows:</p>
  
  <pre><code>//  global variable
  var ONEDAY = 24*60*60*1000; // hours*minutes*seconds*milliseconds
  
  function _mySimpleCalculateDaysDifference(DateToBeChecked)
  {
    var todaysDate = new Date();
    var todaysDayModifier = todaysDate.getHours()&lt;6?-1:0;
    var daysDiff = (todaysDate.getTime() - DateToBeChecked.getTime())/ONEDAY;
    return Math.floor(daysDiff) + todaysDayModifier;
  }
  </code></pre>
  
  <p>It's being called the following way:</p>
  
  <pre><code>=if((H18&gt;0),(H18-F18),if((F18&gt;0),_mySimpleCalculateDaysDifference(F18),""))
  </code></pre>
  
  <p>where <code>F</code> and <code>H</code> columns contain date values.</p>
  
  <p>Is there any way to solve that problem?  </p>
  
  <p><strong>Edit:</strong><br>
  I mentioned that the main spreadhsheet is the newest Google spreadsheet, but those being pulled in were 'old'.</p>