避免通过VBA数组循环

使用从( http://www.cpearson.com/Excel/PassingAndReturningArrays.htm )采取下面的代码是有办法避免在这两个函数循环:

Sub AAATest() Dim StaticArray(1 To 3) As Long Dim N As Long StaticArray(1) = 1 StaticArray(2) = 2 StaticArray(3) = 3 PopulatePassedArray Arr:=StaticArray For N = LBound(StaticArray) To UBound(StaticArray) Debug.Print StaticArray(N) Next N End Sub Sub PopulatePassedArray(ByRef Arr() As Long) '''''''''''''''''''''''''''''''''''' ' PopulatePassedArray ' This puts some values in Arr. '''''''''''''''''''''''''''''''''''' Dim N As Long For N = LBound(Arr) To UBound(Arr) Arr(N) = N * 10 Next N End Sub 

例如,我想它看起来像这样:

 Sub AAATest() Dim StaticArray(1 To 3) As Long Dim N As Long StaticArray(1) = 1 StaticArray(2) = 2 StaticArray(3) = 3 PopulatePassedArray Arr:=StaticArray Debug.Print StaticArray(:,1) End Sub Sub PopulatePassedArray(ByRef Arr() As Long) '''''''''''''''''''''''''''''''''''' ' PopulatePassedArray ' This puts some values in Arr. '''''''''''''''''''''''''''''''''''' Dim N As Long Arr = Arr * 10 End Sub 

但显然这后面的代码不编译。 有什么想法吗?