结果不返回完整数组,而是单个值

时间:2019-07-29 04:11:41

标签: excel vba

我试图创建一个函数来将t行从数组中移出。一切正常,除了结果返回一个值。

Option Explicit
Option Base 1
Function ShiftVector(rng As Range, n As Integer) As Variant
Dim i As Integer, t As Integer
Dim A() As Variant
Dim nrow As Integer

nrow = rng.Rows.Count
n = n Mod nrow

ReDim A(nrow) As Variant

For i = 1 To nrow
t = (i + n) Mod nrow
If t = 0 Then t = nrow
A(i) = rng(t)
Next i

ShiftVector = A

End Function

输出数组中的所有值恰好返回行移位数的一个值。

0 个答案:

没有答案