答案 0 :(得分:0)
你可以尝试一下。请查看列并更新您的方案
Public Sub DataRearrange()
Dim LastRowInSet As Long, LastCol As Long, LastRowInTransposedData As Long, ColumnIncrease As Long
Dim j As Long
' Change this to the width of your repeating data set
ColumnIncrease = 4
' Change this to your relevant Sheet Name
With Sheets("InsertYoursheetNameHere")
LastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
' There's no point doing it if there's only one set so lets Exit
If LastCol <= ColumnIncrease Then Exit Sub
For j = ColumnIncrease + 1 To LastCol Step ColumnIncrease
LastRowInSet = .Cells(.Rows.Count, j).End(xlUp).Row
LastRowInTransposedData = .Cells(.Rows.Count, 1).End(xlUp).Row
Range(.Cells(LastRowInTransposedData + 1, 1), .Cells(LastRowInTransposedData + LastRowInSet, ColumnIncrease)).Value2 = Range(.Cells(1, j), .Cells(LastRowInSet, j + ColumnIncrease - 1)).Value2
Range(.Cells(1, j), .Cells(LastRowInSet, j + ColumnIncrease - 1)).Clear
Next j
End With
End Sub