|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Option Explicit
Sub test1()
Dim ar, br, i&, j&, n&, iRowCount&
ar = Range("A1", Cells(Rows.Count, "A").End(xlUp)).Value
arrGetRnd1 ar
iRowCount = -Int(-UBound(ar) / 10)
ReDim br(1 To iRowCount, 1 To 10)
For j = 1 To UBound(br)
For i = 1 To UBound(br)
n = n + 1
If n > UBound(ar) Then GoTo ExitLine
br(i, j) = ar(n, 1)
Next i
Next j
ExitLine:
Range("B2:K" & Rows.Count).ClearContents
[B2].Resize(UBound(br), UBound(br, 2)) = br
Beep
End Sub
Function arrGetRnd1(ByRef ar)
Dim xNum&, i&, n&, vTemp
Randomize
n = UBound(ar)
For i = 1 To UBound(ar)
xNum = Int((n - i + 1) * Rnd() + i)
vTemp = ar(xNum, 1): ar(xNum, 1) = ar(i, 1): ar(i, 1) = vTemp
Next
End Function
|
评分
-
1
查看全部评分
-
|