在所需的时间内将数据从一行移到另一列

我需要在另一列行中转置一行文本,如下所示:(需要将A1复制到相关行2中的E1文本(此处为A2到E3)次)

ABCDEF 1 Ab1 Ab2 Ab3 Ab4 Ab5 Total 2 3 2 1 3 1 10 3 4 Ab1 5 Ab1 6 Ab1 7 Ab2 8 Ab2 9 Ab3 10 Ab4 11 Ab4 12 Ab4 13 Ab5 

 Sub TransposeData() Dim SourceData As Variant, Results As Variant, i As Long, j As Long, k As Long SourceData = Range("A1:E2").Value Results = Range("A4:A20000").Value For i = 1 To UBound(SourceData, 2) For j = 1 To SourceData(2, i) k = k + 1 Results(k, 1) = SourceData(1, j) Next Next Range("A4:A20000").Value = Results End Sub 

这将通过Row1循环

 Sub Move_It() Dim sh As Worksheet Dim col As Long Dim rng As Range Dim c As Range, x, y Set sh = Sheets("Sheet1") 'actual name of worksheet With sh col = .Cells(1, .Columns.Count).End(xlToLeft).Column Set rng = .Range(.Cells(1, 1), .Cells(1, col)) For Each c In rng.Cells 'loop through row 1 x = c.Offset(1) For y = 1 To x .Cells(.Rows.Count, "A").End(xlUp).Offset(1) = c Next y Next c End With End Sub 
  • select来源范围 – >右键单击 – >“复制”;
  • select目标范围左上angular的单元格 – >右键单击 – >“select性粘贴” – >“select性粘贴”对话框 – >选中“移调”checkbox – >单击“确定”

您可以将其logging为一个macros。