6,210
社区成员
发帖
与我相关
我的任务
分享
Sub test()
Sheets("sheet2").Select
[A:C].ClearContents
With Sheets("Sheet1")
[A1].Select
Selection.Consolidate Sources:="[Book1]Sheet1!C1:C2", Function:=xlSum, TopRow:=True, LeftColumn:=True, CreateLinks:=False 'book1是文件名,要根据实际修改。
For i = 2 To .[C65536].End(xlUp).Row
x = Application.WorksheetFunction.Match(.Cells(i, 1), [A:A], 0)
If Application.WorksheetFunction.CountIf(Cells(x, 3), "*" & .Cells(i, 3) & "*") = 0 Then
If Cells(x, 3) = "" Then
Cells(x, 3) = CStr(.Cells(i, 3))
Else
Cells(x, 3) = Cells(x, 3) & ";" & .Cells(i, 3)
End If
End If
Next i
End With
End Sub