|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub qs() '2024/7/2
Dim arr, dic, i
With Sheet1
arr = .Range("a1").CurrentRegion.Value
Set dic = CreateObject("scripting.dictionary")
For i = 2 To UBound(arr)
s = arr(i, 3)
If Not dic.exists(s) Then
dic(s) = Array(arr(i, 1), 1)
Else
If InStr(dic(s)(0), arr(i, 1)) = 0 Then
dic(s) = Array(dic(s)(0) & "、" & arr(i, 1), dic(s)(1) + 1)
End If
End If
Next
For i = 2 To UBound(arr)
If dic(arr(i, 3))(1) > 1 Then
arr(i, 5) = dic(arr(i, 3))(0)
End If
Next
.Range("e1").Resize(UBound(arr), 1) = Application.Index(arr, 0, 5)
End With
End Sub |
|