这句数组赋值怎么说我REDIM无效?
Public Function TrimArray(arr As Variant) As Variant
Dim k As Integer
k = 0
For i = 0 To UBound(arr)
If arr(i) <> "" Then
ReDim Preserve TrimArray(k)
TrimArray(k) = arr(i)
k = k + 1
End If
Next i
End Function
[解决办法]
ReDim Preserve TrimArray(k)
===================
ReDim 应该是一个变量,不能是函数名
你可以使用 ReDim Preserve aArr(k)
然后:
你的动作
最后:
TrimArray=aArr
[解决办法]
只有事先定义为数组才能redim 为数组。