对应重复列的数据转成一行

问题:C列相同的,GH两列的内容横向排成一行

 

Sub Test()
Dim MyRow As Long, MyCol As Long
For MyRow = Cells(Rows.Count, 3).End(xlUp).Row To 2 Step -1
    If Cells(MyRow, 3) = Cells(MyRow - 1, 3) Then
        MyCol = Cells(MyRow, Columns.Count).End(xlToLeft).Column - 6
        Cells(MyRow - 1, 9).Resize(1, MyCol) = Cells(MyRow, 7).Resize(1, MyCol).Value
        Cells(MyRow, 3).EntireRow.Delete
    End If
Next
End Sub

 

posted @ 2023-04-16 17:52  熬肥妖  阅读(44)  评论(0编辑  收藏  举报