|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 xwdys 于 2016-3-22 11:26 编辑
Sub test() Dim i&, j&, k&, s$, regx Dim mat As Object s = Selection.Range Set regx = CreateObject("vbscript.regexp") regx.Pattern = "(\d+\.?\d+)" regx.Global = True Set mat = regx.Execute(s) For i = 0 To mat.Count - 1 j = mat.Item(i).firstindex k = mat.Item(i).Length If j <> 0 Then s = Left(s, j) & VBA.Replace(s, mat.Item(i), mat.Item(i) * 2, j + 1, k) Else s = Replace(s, Left(s, k), Val(Left(s, k)) * 2) End If Next Selection.Range = s End Sub |
|