小编meg*_*off的帖子

在数组末尾添加一个元素

我想在 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)

vba microsoft-excel

15
推荐指数
2
解决办法
27万
查看次数

标签 统计

microsoft-excel ×1

vba ×1