|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 182197315 于 2018-8-15 21:50 编辑
Sub 统计()
Dim i%, k%, mat, d, reg, sr$
Set d = CreateObject("scripting.dictionary")
Set reg = CreateObject("VBScript.RegExp")
With reg
.Global = True
.Pattern = "\d+.\[江西\]\[地行\]([一-龢]+)"
Set mat = .Execute(ActiveDocument.Content)
End With
For i = 0 To mat.Count - 1
d(mat(i).SubMatches(0)) = d(mat(i).SubMatches(0)) + 1
Next
For k = 0 To d.Count - 1
If sr <> "" Then sr = sr & ","
sr = sr & d.Keys()(k) & d.Items()(k) & "次"
Next
Debug.Print sr
End Sub |
|