|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub ss()
- Dim i, arr, mh
- arr = Sheet1.Range("A1").CurrentRegion
- Sheet1.Range("B2:B" & UBound(arr)).ClearContents
- With CreateObject("vbscript.regexp")
- .Global = True
- .Pattern = "[票税]号.([0-9,,、-]+)"
- For i = 2 To UBound(arr)
- If .test(arr(i, 1)) Then
- Set mh = .Execute(arr(i, 1))
- arr(i, 2) = mh(0).submatches(0)
- If InStr(",,、", Right(arr(i, 2), 1)) Then '去掉结尾的【,,、】
- arr(i, 2) = Left(arr(i, 2), Len(arr(i, 2)) - 1)
- End If
- End If
- Next i
- Sheet1.Range("A1:B" & UBound(arr)) = arr
- End With
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|