|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 tcdatongye 于 2023-8-17 07:52 编辑
Sub 提取()
Set reg = CreateObject("vbscript.regexp")
reg.ignorecase = True
With Sheets(2)
k = .Cells(1, 2).End(xlDown).Row
For I = 1 To k
reg.Pattern = "^\s*.*?([^/]*?°[^/]*).*|^[一-龡]+/([^/]+/)?(\d+([m-z][hf])?)/.*"
If reg.test(.Cells(I, 2)) Then
.Cells(I, 9) = "'" & reg.Replace(.Cells(I, 2), "$1$3")
Else
reg.Pattern = "^\s*.*?((?=[^/]*?[a-z])([^\(/一-龡]*\d+[^\(/一-龡]*)+).*"
.Cells(I, 9) = reg.Replace(.Cells(I, 2), "$1")
End If
Next I
End With
End Sub
这个比较准确 |
|