|
- Sub ss()
- Dim ar, br, l&, h&, i&, j&, u1&, u2&, x&, y&
- l = 5 '希望列数
- h = 5 '1行展开成几行
- With Sheet1
- ar = .Range("A1:D" & .Cells(.Rows.Count, 1).End(3).Row) '取数
- u1 = UBound(ar): u2 = UBound(ar, 2)
- ReDim br(1 To -Int(-u1 / l) * h, 1 To (u2 + 1) * l)
- End With
- For i = 1 To u1
- x = Int((i + l - 1) / l) * h
- y = ((i + l - 1) Mod l) * (u2 + 1)
- For j = 1 To u2
- br(x, y + j) = ar(i, j)
- Next
- Next
- '回填在sheet2
- Sheet2.Cells.ClearContents
- Sheet2.Cells.HorizontalAlignment = xlHAlignCenter
- Sheet2.[A1].Resize(UBound(br), UBound(br, 2)) = br
- End Sub
复制代码 |
评分
-
2
查看全部评分
-
|