|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Option Explicit
Sub TEST1()
Dim ar, br, i&
Application.ScreenUpdating = False
With [A1].CurrentRegion
ReDim ar(1 To .Rows.Count)
For i = 1 To UBound(ar)
Set ar(i) = .Rows(i)
Next i
End With
br = arrLocated(UBound(ar), 5, 5, 5)
With [F1]
For i = 1 To UBound(ar)
ar(i).Copy .Cells(br(i, 1), br(i, 2))
Next i
End With
Application.ScreenUpdating = True
Beep
End Sub
Function arrLocated(ByVal iCount&, ByVal iColNum&, ByVal iStepRows&, ByVal iStepColumns&)
Dim ar, i&, n&, y&, x&
ReDim ar(1 To iCount, 1 To 2)
For i = 1 To UBound(ar)
n = IIf(i Mod iColNum = 0, iColNum, i Mod iColNum)
y = (-Int(-(i / iColNum)) - 1) * iStepRows + 1
x = (n - 1) * iStepColumns + 1
ar(i, 1) = y: ar(i, 2) = x
Next i
arrLocated = ar
End Function |
|