|
本帖最后由 doitbest 于 2015-7-14 19:14 编辑
Public Sub abc()
Dim ar, rep, i, ii, str, tmp, d
Set d = CreateObject("Scripting.Dictionary")
ar = Range([a2], [a65536].End(3))
Set rep = CreateObject("vbscript.regexp")
rep.Global = True
For i = 1 To UBound(ar)
rep.Pattern = "\d+#"
If ar(i, 1) <> "" Then
ar(i, 1) = rep.Replace(ar(i, 1), "")
ar(i, 1) = Replace(ar(i, 1), " ", ";")
str = Split(ar(i, 1), ";")
For ii = 0 To UBound(str)
str(ii) = StrConv(str(ii), 3)
If IsNumeric(str(ii)) And Not Sheet2.[b:b].Find(str(ii), , , 1) Is Nothing Then
str(ii) = Sheet2.[b:b].Find(str(ii), , , 1).Offset(, 1)
End If
d(str(ii)) = d(str(ii)) + 1
Next
For ii = 0 To UBound(str)
If d(str(ii)) > 1 Then
d(str(ii) & "@") = d(str(ii) & "@") + 1
tmp = tmp & " " & str(ii) & d(str(ii) & "@")
Else
tmp = tmp & " " & str(ii)
End If
Next
ar(i, 1) = Replace(Trim(tmp), " ", ",")
tmp = ""
d.RemoveAll
End If
Next
[b2].Resize(UBound(ar)) = ar
End Sub
|
|