I've created dynamic formulas in excel. Unfortunately, it creates the formula as a string. To get around this I created a function (Evalu) that using the Evaluate() function to give me the answer. This currently works fine.
However, the problem I now is how to apply this to an array. My formula currently evaluates to
=evaluS({"100*100+0";"50*10+0";"0*0+0"})
before it breaks. I'm trying to get to the result of 10500 by adding each array element together. Notice that each element in the array is a string, that I want to get evaluated as a formula.
To do this, I create the evaluS function:
Function EvaluS(S() As String) As String
Dim i As Long
Dim A As Integer
Dim Arr As String
For i = LBound(S) To UBound(S)
Arr = S(i)
A = A + Evaluate(Arr)
Next
EvaluS = A
End Function
Clearly this approach isn't working very well, and since I'm a VBA expert, I was hoping someone could show me the error of my ways.
However, the problem I now is how to apply this to an array. My formula currently evaluates to
=evaluS({"100*100+0";"50*10+0";"0*0+0"})
before it breaks. I'm trying to get to the result of 10500 by adding each array element together. Notice that each element in the array is a string, that I want to get evaluated as a formula.
To do this, I create the evaluS function:
Function EvaluS(S() As String) As String
Dim i As Long
Dim A As Integer
Dim Arr As String
For i = LBound(S) To UBound(S)
Arr = S(i)
A = A + Evaluate(Arr)
Next
EvaluS = A
End Function
Clearly this approach isn't working very well, and since I'm a VBA expert, I was hoping someone could show me the error of my ways.