来个数组的,参与一下
Application.ScreenUpdating = False
arr = [a2].CurrentRegion
ReDim brr(1 To UBound(arr), 1 To UBound(arr, 2))
For i = 2 To UBound(arr)
If Len(arr(i, 1)) Then
m = m + 1
For j = 1 To UBound(arr, 2)
brr(m, j) = arr(i, j)
Next
For k = i + 1 To UBound(arr)
If Len(arr(k, 1)) Then
If arr(k, 1) = arr(i, 1) And arr(k, 2) = arr(i, 2) Then
brr(m, 3) = brr(m, 3) & "," & arr(k, 3)
arr(k, 1) = vbNullString
End If
End If
Next
End If
Next
If m > 0 Then
Range("i2:k10000").ClearContents
[i2].Resize(m, 3) = brr
End If
Application.ScreenUpdating = True |