|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
* 楼主,下面的宏请放在 标准模块 NewMacros 中使用,且仅适用于“+”(加法):
- Sub a1002_Calculate()
- Dim x$, y$, s$, t$
- With Selection
- .HomeKey 6
- Do
- Do
- .MoveRight 1, 1, 1
- Loop Until Not .Next Like "#"
- x = .Text
- .MoveRight 1, 2
- .Extend vbCr
- .MoveEnd 1, -1
- y = .Text
- s = Val(x) + Val(y)
- t = t & vbCr & s
- If .Paragraphs(1).Range.End = ActiveDocument.Content.End Then Exit Do
- .Move 4
- If .Paragraphs(1).Range.Text = vbCr Then Exit Do
- Loop
- End With
- Documents.Add.Content.Text = t
- ActiveDocument.Paragraphs(1).Range.Delete
- Selection.WholeStory
- Selection.Cut
- ActiveDocument.Close 0
- ActiveDocument.Close 0
-
- 'verify
- Documents.Add
- Selection.Paste
- End Sub
复制代码 |
|