我试图创建一个函数来将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
输出数组中的所有值恰好返回行移位数的一个值。