数组大小限制在VBA中传递数组参数

Mar*_*ult 5 arrays excel vba excel-vba

Excel-VBA 2007似乎对作为参数传递的数组的大小有64k的限制.

有人知道修复或解决方法吗?

这是代码:

Public Function funA(n)
    Dim ar()
    ReDim ar(n)
    funA = ar
End Function

Public Function funB(x)
    funB = UBound(x)
End Function
Run Code Online (Sandbox Code Playgroud)

来自Excel:

=funB(funA(2^16-1))   '65536 as expected

=funB(funA(2^16))    'Gives a #VALUE
Run Code Online (Sandbox Code Playgroud)

在里面看,funA()工作正常但是,传递给funB,参数x是一个错误2015.

Bra*_*rad 3

这似乎是我能找到的最接近的解决方法。从 VBA 进行函数间调用

如果你做了这样的事情

Public Function funBA(n As Variant) As Variant
    funBA = funB(funA(n))
End Function
Run Code Online (Sandbox Code Playgroud)

它似乎可以工作到n=2^24=2^8^3(这看起来不像VBA中的任何数据类型断点,这是挂起的地方,但这是一个相当大的数组)