|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub TEST1()
Dim Rng As Range, rngFind As Range, strFirstAddress$
Dim ar, i&, dic As Object, vKey
Set dic = CreateObject("Scripting.Dictionary")
ar = Sheets(2).[A1].CurrentRegion
For i = 2 To UBound(ar)
If ar(i, 2) <> "" Then
vKey = ar(i, 2)
If dic.exists(vKey) Then
dic(vKey) = dic(vKey) & vbLf & ar(i, 3) & ":" & ar(i, 4)
Else
dic(vKey) = ar(i, 3) & ":" & ar(i, 4)
End If
End If
Next i
Set Rng = [A2:G13]
For Each vKey In dic.keys
Set rngFind = Rng.Find(vKey, , , xlWhole)
If Not rngFind Is Nothing Then
rngFind.Offset(1) = dic(vKey)
End If
Next
Set Rng = Nothing: Set rngFind = Nothing
Beep
End Sub
|
|