|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub AA()
- Dim ar, i, d, d1, k, ar1(), m, s
- Set d1 = CreateObject("vbscript.regexp")
- Set d = CreateObject("scripting.dictionary")
- With d1
- .Global = True
- .Pattern = "\d+楼"
- End With
- With Sheet1
- ar = .UsedRange
- ReDim ar1(1 To UBound(ar), 1 To 2)
- For i = 2 To UBound(ar)
- s = d1.Execute(ar(i, 1))(0)
- If Not d.exists(ar(i, 2)) Then
- k = k + 1
- ar1(k, 1) = ar(i, 2)
- d(ar(i, 2)) = k & "/" & s
- ar1(k, 2) = Split(d(ar(i, 2)), "/")(1)
- d(ar(i, 2) & s) = ""
- Else
- If Not d.exists(ar(i, 2) & s) Then
- m = Split(d(ar(i, 2)), "/")(0)
- d(ar(i, 2) & s) = ""
- ar1(m, 2) = ar1(m, 2) & "/" & d1.Execute(ar(i, 1))(0)
- End If
- End If
- Next
- .[f2].Resize(UBound(ar1), UBound(ar1, 2)) = ar1
- End With
- Set d = Nothing
- Set d1 = Nothing
- End Sub
复制代码 |
|