|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
把以下代码复制到vbe编辑器运行就可以了
- Sub Test()
- Dim aras As Range, sht As Worksheet
- ipt = InputBox("请输入要调整的数字,例如1或者0.25")
- If ipt = "" Then
- MsgBox "请输入有效数字"
- Exit Sub
- End If
- ope = InputBox("请输入要计算的运算符,例如+或者-")
- If ope = "" Then
- MsgBox "请输入运算符"
- Exit Sub
- End If
- For Each sht In ThisWorkbook.Worksheets
- For Each aras In sht.Range("A1:A100")
- If InStr(aras, "里程桩号") Then
- vl = aras.Offset(0, 1).Value
- Exit For
- End If
- Next
- sr = Left(vl, InStrRev(vl, "+"))
- nubr = Val(Trim(Right(vl, Len(vl) - InStrRev(vl, "+"))))
- If ope = "+" Then
- vul = nubr + ipt
- ElseIf ope = "-" Then
- vul = nubr - ipt
- End If
- aras.Offset(0, 1) = sr & vul
- Next
- End Sub
复制代码 |
|