Hallo Chris,
Probiers mal mit diesem stark vereinfachen Code:
Function Berechnungsweg2(r As Range) As String
Dim f As String, f2 As String
f = r.FormulaLocal
f2 = f
f2 = Replace(f2, "+", ";")
f2 = Replace(f2, "-", ";")
f2 = Replace(f2, "*", ";")
f2 = Replace(f2, "/", ";")
f2 = Replace(f2, "^", ";")
f2 = Replace(f2, ":", ";")
f2 = Replace(f2, "(", ";")
f2 = Replace(f2, ")", "")
arr = Split(f2, ";")
For Each x In arr
If Not getRange(x) Is Nothing Then
If getRange(x).NumberFormat = "General" Then
f = Replace(f, x, getRange(x))
Else
f = Replace(f, x, Format(getRange(x).Value, getRange(x).NumberFormat))
End If
End If
Next x
Berechnungsweg2 = f
End Function
Function getRange(ByVal bez As String) As Range
On Error Resume Next
Set getRange = Range(bez)
End Function
Gruß Mr. K.
|