|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 按钮1_Click()
r = Cells(Rows.Count, 8).End(3).Row
arr = [a1].Resize(r, 8)
With CreateObject("vbscript.regexp")
.Global = True
For j = 2 To UBound(arr)
.Pattern = "[^一-龥]+"
arr(j, 8) = .Replace(arr(j, 8), "")
If InStr(arr(j, 8), "玉树藏族自治州") > 0 Then
arr(j, 1) = "玉树藏族自治州"
arr(j, 2) = "玉树藏族自治州"
Else
.Pattern = "^(.+?(省|自治区|市))(.+?(市|自治州|旗|地区|自治县|县))"
If .test(arr(j, 8)) Then
Set m = .Execute(arr(j, 8))
arr(j, 1) = m(0).submatches(0)
arr(j, 2) = m(0).submatches(2)
End If
End If
Next j
End With
[a1].Resize(r, 8) = arr
End Sub
|
评分
-
1
查看全部评分
-
|