我这里 1.xls 与 2.xls 都有结果
================
Ps:
减了 2 个 replace函数
Function tt(str)
With CreateObject("vbscript.regexp")
.Global = True
.Pattern = "(\[.+?\])|(\ )"
str = .Replace(str, "")
End With
str = Replace(Replace(str, "{", "("), "}", ")")
str = Replace(Replace(str, "×", "*"), "÷", "/") '"×") '÷
tt = Application.Evaluate(str)
End Function
------------------------------------------------
这样不用replace函数
Function tt(str)
Dim i, p1, p2
p1 = Array("(\[.+?\])|(\ )", "{", "}", "×", "÷")
p2 = Array("", "(", ")", "*", "/")
With CreateObject("vbscript.regexp")
.Global = True
For i = 0 To UBound(p1)
.Pattern = p1(i)
str = .Replace(str, p2(i))
Next i
End With
tt = Application.Evaluate(str)
End Function |