title: Returning Empty from user defined function returns actually 0
body: <p>I need to fill a cell with the result of a user function. If the result of the function is different from zero, the cell should be simply filled with the result of the function; so far so good.</p>
  
  <p>But if the result is zero I want the cell to be empty.</p>
  
  <p>So I wrote this user defined function:</p>
  
  <pre><code>Function MyTestFunction(n As Integer) As Integer
      Dim result As Integer
  
      result = n * 2
  
      If result = 0 Then
          MyTestFunction = Empty
      Else
          MyTestFunction = result
      End If
  End Function
  </code></pre>
  
  <p>The function has no real purpose, it's just for investigating this issue.</p>
  
  <p>The Excel sheet is like follows:</p>
  
  <p><img src="https://i.stack.imgur.com/HL6jE.png" alt="enter image description here"></p>
  
  <p>Cells A1 to A3 is just typed in data, cells B1 to B3 contain:</p>
  
  <ul>
  <li>B1:  <code>=MyTestFunction(A1)</code></li>
  <li>B2:  <code>=MyTestFunction(A2)</code></li>
  <li>B3:  <code>=MyTestFunction(A3)</code></li>
  </ul>
  
  <p>Now why does cell B3 display <code>0</code> instead of being empty ?</p>