|
Option Explicit
Sub TEST1()
Dim ar, br, i&, j&, r&, aMatch As Object, dic As Object, vKey
Set dic = CreateObject("Scripting.Dictionary")
ar = Range("A1", Cells(Rows.Count, "A").End(xlUp)).Value
ReDim br(1 To UBound(ar) * 2, 0)
With CreateObject("VBScript.RegExp")
.Pattern = "【.+?】"
For i = 1 To UBound(ar)
If .test(ar(i, 1)) Then
Set aMatch = .Execute(ar(i, 1))(0)
dic(aMatch.Value) = dic(aMatch.Value) & "," & .Replace(ar(i, 1), "")
End If
Next i
End With
For Each vKey In dic.keys
r = r + 1
br(r, 0) = vKey
ar = Split(dic(vKey), ",")
For j = 1 To UBound(ar)
r = r + 1
br(r, 0) = ar(j)
Next j
Next
Columns("B").Clear
[B1].Resize(r) = br
Beep
End Sub
|
|