答:我写了段代码,假设原始数据在A:D列(可根据实际修改),生成结果在U1开始的单元格。
Sub Demo()
Dim AllBlock As Range
Dim AreaRng As Range
Dim DesRng As Range
Set AllBlock = Range("A:D").SpecialCells(xlCellTypeConstants, 23)
Set DesRng = Range("U1")
For Each AreaRng In AllBlock.Areas
With AreaRng
For i = 1 To .Columns.Count
DesRng = .Cells(1, i)
DesRng.Offset(0, 1) = .Cells(1, i).Offset(1, 0)
Set DesRng = DesRng.Offset(1, 0)
Next i
End With
Next AreaRng
MsgBox "Completed!"
End Sub
效果图:
代码可以做的,发你的表格到3271614433QQ邮箱。