Using this very simple function:
Function WriteArray() as Variant
Dim array(0 To 2)
array(0) = "A"
array(1) = "B"
array(2) = "C"
WriteArray = array
End Function
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.
I also tried to use the Application.Caller variable to write directly in the "Caller" range but the code breaks.
Thanks a lot for your help!
EDIT: Here is another code I tried to use:
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" & i).Value = arr(i)
Next
End Function
It breaks at the line "Range("A" & i).Value = arr(i)". Is my Excel broken?!