Sub test()
Dim Arr, Brr(), i&, s%, k%, n%, x%
Arr = Range([a3], [c65536].End(3))
ReDim Brr(1 To UBound(Arr), 1 To 16)
For i = 1 To UBound(Arr)
s = s + 1: k = k + 1
For j = 1 To 3
n = n + 1: Brr(n, k) = Arr(i, j)
Next j
If s = 16 Then
x = x + 1: R = R + s
n = R / 16 * 3 + x
k = 0: s = 0
Else
If n < 4 Then n = 0 Else n = n - 3
End If
Next
Range("h12").Resize((x + 1) * 4, 16) = Brr
End Sub作者: samwang 時間: 2021-6-10 17:31
Sub 轉置()
Dim Arr, Brr, C%(2), r%, i&, j%
ActiveSheet.UsedRange.Offset(, 7).EntireColumn.Delete
Arr = Range([a3], [c65536].End(3))
ReDim Brr(1 To 8, 1 To 200)
For i = 2 To UBound(Arr)
r = IIf(Arr(i, 1) > 6, 1, 0): C(r) = C(r) + 1
For j = 1 To 3
Brr(r * 4 + j, C(r)) = Arr(i, j)
Next j
If C(r) > C(2) Then C(2) = C(r)
Next i
With [h2].Resize(UBound(Brr), C(2))
.Value = Brr
.Borders.LineStyle = 1
.ColumnWidth = 4
.Font.Size = 14
End With
End Sub
# 3 樓回答,應該就是您的需求,請再測試看看,謝謝。
Sub test()
Dim Arr, Brr(), i&, s%, k%, n%, x%
Arr = Range([a3], [c65536].End(3))
ReDim Brr(1 To UBound(Arr), 1 To 16)
For i = 1 To UBound(Arr)
s = s + 1: k = k + 1
For j = 1 To 3
n = n + 1: Brr(n, k) = Arr(i, j)
Next j
If s = 16 Then
x = x + 1: R = R + s
n = R / 16 * 3 + x
k = 0: s = 0
Else
If n < 4 Then n = 0 Else n = n - 3
End If
Next
Range("h2").Resize((x + 1) * 4, 16) = Brr
End Sub作者: dou10801 時間: 2021-6-19 09:10