I am trying to find out what is wrong with the process below. In my sheet, there is a formula string which needs evaluation for different values of variable, x.
(0.5*(23-9.81)*3*(x^2))*(x/3)+(0.5*9.81*(x^2))*(x/3)-1*((0.5*18.5*0.33*(2.5^2))*(x+2.5/3)+(18.5*0.33*2.5*x)*(x/2)+(0.5*(23-9.81)*0.33*(x^2))*(x/3)+(0.5*9.81*(x^2))*(x/3)+(100*0.33*(2.5+x))*((2.5+x)/2))
I have a vba code which looks like this:
Public Function ev(r As Range, x As Double) As Variant
ev = Application.Evaluate(Replace(r.Value, "x", x))
End Function
What's weird is that this function only works if the cell input is like
=ev(Q25,10.01)
but not
=ev(Q25,10.000000001)
or even
=ev(Q25,10.00001)
Why is this happening? I need the program to calculate using small increments of up to 0.0000000001. Thank you for your insights.
A1instead ofxin your formula and simply change the value in A1 ?