excel,如何快速有效实现分多列(按照内容分)?

如图,除了复制粘贴,有没有什么公式或快捷方法,能将左边两列数据快速分成右边那样的?

直接给VBA代码吧!VBA 操作步骤:  1、 打开你要处理的表(请处理前一定备份你的数据表);2、按住ALT + F11 ,双击ThisWorkbook,在出现的界面粘贴代码,见下图:

3、粘贴好代码后,按F5(或者直接点击 有“通用”字样上方那个小三角形),然后静等结果。

4、运行结果如下图:

最后:由于不知道你的数据量,整个数据能处理的初始为 1000 行,如果你的数据超过1000行,请再联系我。或者你自行修改代码中“1000”的地方。

友情提示:处理数据前,请注意数据备份。

Sub ReSort()
    Dim i As Integer
    For i = 2 To 1000
        If Cells(i, 1) <> "" And Cells(i, 1) <> Cells(i - 1, 1) Then
           Dim j As Integer
           For j = 4 To 1000 Step 2
             If Cells(2, j) = "" Then
                Cells(2, j) = Cells(i, 1)
                Exit For
             End If
           Next j
        End If
    Next i
    Dim i2 As Integer
    For i2 = 2 To 1000
    If Cells(i2, 1) <> "" Then
       Dim j2 As Integer
       For j2 = 2 To 1256 Step 2
         If Cells(i2, 1) = Cells(2, j2) Then
            If Cells(2, j2 + 1) = "" Then
               Cells(2, j2 + 1) = Cells(i2, 2)
               Exit For
            End If
            If Cells(2, j2 + 1) <> "" Then
               Dim n As Integer
               For n = 1 To 201
                If Cells(2 + n, j2 + 1) = "" And Cells(n + 1, j2 + 1) <> "" Then
                   Cells(n + 2, j2) = Cells(i2, 1)
                   Cells(n + 2, j2 + 1) = Cells(i2, 2)
                   Exit For
                End If
               Next n
            End If
            Exit For
         End If
       Next j2
    End If
    Next i2
End Sub
温馨提示:答案为网友推荐,仅供参考
第1个回答  2018-09-20

用VBA代码完成

第2个回答  2018-09-20
代码最快捷,只是要付费
第3个回答  2018-09-20
用vba处理是世界上最快的办法
相似回答