|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 hhjjpp 于 2016-10-24 10:57 编辑
- Private Sub CommandButton1_Click()
- Application.ScreenUpdating = False
- Dim reg, mh, mhk, i%
- Set reg = CreateObject("vbscript.regexp")
- reg.Pattern = "\d+(\.\d+)?" '无法附加[^%\d]?进行限定;因为Submatches没有FirstIndex和Length属性,无法用括号提取准确位置
- reg.Global = True
- For i = 3 To [d13].End(xlUp).Row + 1
- Set mh = reg.Execute(Cells(i, 4))
- For Each mhk In mh
- If Mid(Cells(i, 4), mhk.FirstIndex + mhk.Length + 1, 1) <> "%" Then
- Cells(i, 4).Characters(Start:=mhk.FirstIndex + 1, Length:=mhk.Length).Font.Underline = xlUnderlineStyleSingle
- End If
- Next
- Next
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|