假定数据在sheet1的A、B两列,轩置后的数据放在Sheet2表里,代码如下。详见附件
Sub 转置8行()
Sheet1.Range("A1:A8").Copy
Sheet2.Range("A1").PasteSpecial Transpose:=True
For i = 1 To Sheet1.[b65536].End(3).Row Step 8
Sheet1.Range("B" & i).Resize(8).Copy
Sheet2.Range("A" & (i + 15) / 8).PasteSpecial Transpose:=True
Next
End Sub
Sub MC_TEST()
Set d = CreateObject("Scripting.Dictionary")
For i = 1 To [A65536].End(3).Row
d(Cells(i, 1).Value) = d(Cells(i, 1).Value) & "|" & Cells(i, 2)
Next
ar = d.keys: br = d.items
For n = 0 To d.Count - 1
Cells(1, n + 5) = ar(n)
ss = Split(br(n), "|")
For x = 1 To UBound(ss)
Cells(x + 1, n + 5) = ss(x)
Next
Next
Set d = Nothing
End Sub