用vba
Visual Basic code
?
1
2
3
4
5
6
7
8
9
10
Sub test()
With Sheets("sheet1")
For i = 1 To .[B65536].End(xlUp).Row
If Application.WorksheetFunction.CountIf(.Range(.Cells(1, 2), .Cells(i, 2)), .Cells(i, 2)) = 1 Then Sheets("sheet2").Cells(i, 1) = .Cells(i, 2)
x = Application.WorksheetFunction.Match(.Cells(i, 2), Sheets("sheet2").[A:A], 0)
Sheets("sheet2").Cells(x, Sheets("sheet2").Cells(x, 256).End(xlToLeft).Column + 1) = .Cells(i, 3)
Next i
End With
MsgBox "搞掂了!"
End Sub