|
楼主 |
发表于 2022-12-29 10:33
|
显示全部楼层
Sub test()
Dim arr, i, d, mkey, skey
Dim num As Long
Dim n
Dim brr
With Sheets("重复数据")
arr = .Range("a2:o" & .[d65536].End(xlUp).Row)
num = .[d65536].End(xlUp).Row
End With
Set d = CreateObject("scripting.dictionary")
For i = 1 To UBound(arr)
d(arr(i, 4)) = d(arr(i, 4)) + 1
For n = 1 To 15
d(arr(i, 4)).Item = d(arr(i, 4)).Item & "," & arr(i, n)
Next
Next
For Each mkey In d.keys
If d(mkey) > 1 Then d.Remove mkey
Next
If d.Count > 0 Then _
Sheets ("重复数据"), Range("a1:o" & num).ClearContents
ReDim brr(1 To d.Count)
For n = 1 To d.Count
brr(n) = VBA.Split(d(arr(n, 4)).Item, ",")
Next
Sheets("重复数据").Range("a2").Resize(UBound(d.keys) + 1, 15) = Application.WorksheetFunction.Transpose(brr)
End Sub
实在想不出来了 麻烦老师指导 |
|