我想在 VBA 数组的末尾添加一个值。我怎样才能做到这一点?我在网上找不到一个简单的例子。这是一些伪代码,显示了我希望能够做什么。
Public Function toArray(range As range)
Dim arr() As Variant
For Each a In range.Cells
'how to add dynamically the value to end and increase the array?
arr(arr.count) = a.Value 'pseudo code
Next
toArray= Join(arr, ",")
End Function
Run Code Online (Sandbox Code Playgroud)