I have a function in VBA that generates an array of strings. It works fine when called from another VBA function, but not when called from the worksheet.
Here's how it should be used:
* select A1:A3
* write in the formula bar `=Test()`, then hit `Ctrl-Shift-Enter` to make it an array function
* A1 should contain `A`, A2 should contain `B`, and A3 should contain `C`
When I actually try this, it puts `A` in all three cells of the array. How can I get the data returned by `Test` into the different cells of the array?
For those who'd like to see it, here's the code of the function. Keep in mind, the function works fine when called from other functions.
Function Test() As String()
Dim a(1 To 3) As String
a(1) = "A"
a(2) = "B"
a(3) = "C"
Test = a
以上就是Array function in Excel VBA的详细内容，更多请关注web前端其它相关文章！