|
本帖最后由 爱疯 于 2019-11-4 11:21 编辑
Sub test()
Dim i
Sheets(2).Select
i = Range("d65536").End(xlUp).Row - 1
Call test2([b2].Resize(i).Value, Array(4, 11, 18), 2, 4)
Sheets(2).Select
Call test2([d2].Resize(i).Value, Array(5, 12, 19), 4, 2)
End Sub
'某列(源数据, 源位置, 源列, 目的列 )
Sub test2(B, C, c1, c2)
Dim m, n, A, i, j, s, t
m = 20
n = Int(UBound(B) / 3) + 1
Sheets(1).Select
A = Cells(1, c2).Resize(m * n)
For i = 1 To UBound(B)
For j = 0 To UBound(C)
s = s + 1
t = (i - 1) * m + C(j)
If s <= UBound(B) Then A(t, 1) = B(s, 1)
Next j
Next i
Cells(1, c2).Resize(UBound(A)) = A
End Sub
|
|