|
楼主 |
发表于 2024-10-19 15:25
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub test()
Dim arrarr As Variant, a As Integer
a = Sheets("Sheet1").Range("A65536").End(3).Row
Set d = CreateObject("Scripting.Dictionary")
arr = Sheets("Sheet1").Range("A1:J" & a)
ReDim arrarr(1 To Int(a / 3) + 1, 1 To 30)
For i = 1 To UBound(arr)
If i Mod 3 = 1 Then
For j = 1 To 10
arrarr(Int(i / 3) + 1, j) = arr(i, j)
Next
End If
If i Mod 3 = 2 Then
For j = 1 To 10
arrarr(Int(i / 3) + 1, j + 10) = arr(i, j)
Next
End If
If i Mod 3 = 0 Then
For j = 1 To 10
arrarr(Int(i / 3), j + 20) = arr(i, j)
Next
End If
Next
Sheets("Sheet2").Range("A1").Resize(UBound(arrarr), 30) = arrarr
End Sub
有点笨,自己解决了 |
|