title: In VBA, how to return an array / or write to cells using a function?
body: <p>Using this very simple function:</p>
  
  <pre><code>Function WriteArray() as Variant
   Dim array(0 To 2)
   array(0) = "A"
   array(1) = "B"
   array(2) = "C"
   WriteArray = array
  End Function
  </code></pre>
  
  <p>I was expecting to see in result the whole array in my Excel spreadsheet, but that's not the case: I get only the first string. I know there is trick to show the whole array in the spreadsheet (by selecting a range of cells with the formula + F2 + CTRL+SHIFT+ENTER), but I would prefer VBA to handle it all.</p>
  
  <p>I also tried to use the Application.Caller variable to write directly in the "Caller" range but the code breaks.</p>
  
  <p>Thanks a lot for your help!</p>
  
  <p>EDIT:
  Here is another code I tried to use:</p>
  
  <pre><code>Function WriteArray() As Variant
       Dim arr(0 To 2)
       arr(0) = "A"
       arr(1) = "B"
       arr(2) = "C"
       WriteArray = arr
       Dim StartRow, i As Integer
       For i = 0 To UBound(arr)
          Range("A" &amp; i).Value = arr(i)
       Next
  End Function
  </code></pre>
  
  <p>It breaks at the line "Range("A" &amp; i).Value = arr(i)". Is my Excel broken?!</p>