How can I compute in a cell an expression string such as "sqrt(2)*(5-2)" ?
Not sure exactly what you mean.
First, do you actually have the quotes ("...") in the cell; or do you
have just the text without the quotes?
In either case, the "obvious" answer is: remove the quotes ("..."),
if they are present, and insert an equal sign (=) on the left. In
other words, manually turn the text into a formula.
But if what you mean is: you an expression as text in a cell, and in
another cell, you would like to evaluate the text as an Excel formula,
perhaps the following UDF would be helpful:
function doit(rng as Range)
s = replace(rng.value, chr(34), "")
doit = evaluate(s)
end function
Usage: If A1 contains the expression as text:
=doit(A1)
Note: The Replace() function call is needed only if you might have
explicit quotes in the string expression. If not, remove the "s="
line and "s" with rng.value in the Evaluate() function call.
Use alt+F11 and Insert>Module to enter the text as in the VB Editor.