|
参与一下。。。- Sub ykcbf() '//2024.8.7
- Dim arr, brr, d
- Application.ScreenUpdating = False
- Set d = CreateObject("scripting.dictionary")
- arr = Sheets("数据源").UsedRange
- ReDim brr(1 To UBound(arr), 1 To 2)
- For i = 2 To UBound(arr)
- s = arr(i, 1)
- If Not d.Exists(s) Then
- m = m + 1
- d(s) = m
- brr(m, 1) = arr(i, 1)
- brr(m, 2) = arr(i, 2)
- Else
- r = d(s)
- brr(r, 2) = IIf(InStr(brr(r, 2), arr(i, 2)), brr(r, 2), brr(r, 2) & "," & arr(i, 2))
- End If
- Next
- With Sheets("结果")
- .UsedRange.Offset(3) = ""
- .Range("a4").Resize(m, 2) = brr
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|