ich habe mir eine Funktion gebastelt die auch ganz gut funktioniert.
Ich habe aber ein Problem: es werden auch gesetzte Klammern ignoriert und dadurch rechnet das ganze nicht richtig.
Hier die Funktion:
Function FFormel(txt As String)
Dim i As Integer, j As Integer, strTmp As String
Dim arr1
arr1 = Array("+", "-", "/", "*")
txt = Application.Substitute(txt, " ", "")
txt = Application.Substitute(txt, ",", ".")
txt = Application.Substitute(txt, "x", "*")
txt = Application.Substitute(txt, "X", "*")
txt = Application.Substitute(txt, "×", "*")
txt = Application.Substitute(txt, Chr(248), Chr(216))
j = InStr(txt, Chr(216))
If j > 0 Then
strTmp = Left(txt, j - 1)
j = j + 1
Do While IsNumeric(Mid(txt, j, 1))
j = j + 1
Loop
txt = strTmp & Mid(txt, j)
End If
strTmp = ""
For i = 1 To Len(txt)
If IsNumeric(Mid(txt, i, 1)) Then
strTmp = strTmp & Mid(txt, i, 1)
Else
Select Case Mid(txt, i, 1)
Case "*", "+", "-", "/", ".": strTmp = strTmp & Mid(txt, i, 1)
End Select
End If
Next i
txt = strTmp
Do
For i = 0 To UBound(arr1)
For j = 0 To UBound(arr1)
txt = Application.Substitute(txt, arr1(i) & arr1(j), arr1(i))
Next j
Next i
If strTmp = txt Then
Exit Do
Else
strTmp = txt
End If
Loop
FFormel = Evaluate(txt)
End Function
Was müßte man ändern damit gesetzte Klammern auch berücksichtigt werden?Vielen Dank und viele Grüße
Lutz