1

我有连续的数据。让我们从 A1 到 XFD1,我想每 6 列拆分一次数据。这意味着 A1-F1 原样,从 G1-L1 转移到 A2-F2,依此类推。

例子:

A B C D E F A B C D E F A B C D E F A B C D E F A B C D E F A B C D E F 

我需要这样的:

A B C D E F 
A B C D E F
A B C D E F
A B C D E F
4

1 回答 1

0

此 VBA 例程将起作用。

Sub SplitData()
    Dim data As Range, arr() As Variant
    Dim row As Integer, i As Integer, j As Integer

    Set data = Range(Range("A1"), Range("A1").End(xlToRight))
    arr = data
    data.ClearContents

    row = 1

    On Error Resume Next
    For i = 1 To data.Columns.Count Step 6
        For j = 0 To 5
            Cells(row, j + 1) = arr(1, i + j)
        Next j
        row = row + 1
    Next i
End Sub
于 2013-03-08T17:10:35.627 回答