参与一下。。。
- Sub ykcbf() '//2024.11.11
- Application.ScreenUpdating = False
- Set d = CreateObject("scripting.dictionary")
- With Sheets("Sheet1")
- arr = .UsedRange
- ReDim brr(1 To UBound(arr), 1 To 100)
- For i = 2 To UBound(arr)
- s = arr(i, 5)
- If Not d.exists(s) Then
- m = m + 1
- d(s) = m
- brr(m, 1) = s
- brr(m, 2) = arr(i, 8)
- brr(m, 3) = arr(i, 6)
- brr(m, 4) = arr(i, 7)
- brr(m, 7) = arr(i, 4)
- brr(m, 8) = arr(i, 1)
- Else
- r = d(s)
- brr(r, 2) = brr(r, 2) + arr(i, 8)
- brr(r, 3) = IIf(InStr(brr(r, 3), arr(i, 6)), brr(r, 3), brr(r, 3) & "、" & arr(i, 6))
- brr(r, 4) = IIf(InStr(brr(r, 4), arr(i, 7)), brr(r, 4), brr(r, 4) & "、" & arr(i, 7))
- brr(r, 7) = IIf(InStr(brr(r, 7), arr(i, 4)), brr(r, 7), brr(r, 7) & "、" & arr(i, 4))
- brr(r, 8) = IIf(InStr(brr(r, 8), arr(i, 1)), brr(r, 8), brr(r, 8) & "、" & arr(i, 1))
- End If
- Next
- .[i2].Resize(m, 8) = brr
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|