|
- Option Explicit
- Sub 拆分家庭住址()
- Dim Reg, Mat, Ma, x&, arr2(1 To 10000, 1 To 5), k&
- Dim R&, Arr, Brr, i&, a&
- Application.ScreenUpdating = False
- R = Cells(Rows.Count, 1).End(xlUp).Row
- Arr = Range("a2:a" & R)
- Set Reg = CreateObject("Vbscript.RegExp")
- With Reg
- .Global = True
- .Pattern = "([ \u4e00-\u9fa5]+省)?([ \u4e00-\u9fa5]+市)?([ \u4e00-\u9fa5]*区)?([ \u4e00-\u9fa5]+镇|乡)?(\S+)"
- End With
- For i = 1 To UBound(Arr)
- Set Mat = Reg.Execute(Arr(i, 1))
- For Each Ma In Mat
- For x = 1 To 5
- arr2(i, x) = Reg.Replace(Ma, "$" & x)
- Next x
- Next Ma
- Next i
- [c:g].Clear
- [D:D].NumberFormatLocal = "@"
- [c1].Resize(1, 5) = Array("省市", "地市", "县市区", "乡镇街道办", "具体地址")
- For a = 1 To UBound(arr2)
- If arr2(a, 1) = "" Then
- arr2(a, 1) = "山东省"
- End If
- Next a
- [c2].Resize(i, 5) = arr2
- Range("c:H").EntireColumn.AutoFit
- Range("c1:g" & R).Borders.LineStyle = xlContinuous
- Application.ScreenUpdating = True
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|