Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Compute string content
How can I compute in a cell an expression string such as "sqrt(2)*(5-2)" ?
|
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Compute string content
Put this formula in the cell:
=SQRT(2)*(5-2) and you should get a result like 4.242641 -- David Biddulph "jfkaufeler" wrote in message ... How can I compute in a cell an expression string such as "sqrt(2)*(5-2)" ? |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Compute string content
Thank you for your prompt anwer. I didn't formulate my problem correctly.
What is in the cell is an expression string which was itself computed from other cells (e.g. concatenation of different cell content (values and operators). Regards, "David Biddulph" wrote: Put this formula in the cell: =SQRT(2)*(5-2) and you should get a result like 4.242641 -- David Biddulph "jfkaufeler" wrote in message ... How can I compute in a cell an expression string such as "sqrt(2)*(5-2)" ? |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Compute string content
On Jan 13, 12:54*pm, jfkaufeler
wrote: 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 InsertModule to enter the text as in the VB Editor. |
#5
Posted to microsoft.public.excel.misc
|
|||
|
|||
Compute string content
Many thanks, it looks to answer my question but I didn't have time to try.
Regards, "joeu2004" wrote: On Jan 13, 12:54 pm, jfkaufeler wrote: 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 InsertModule to enter the text as in the VB Editor. |
#6
Posted to microsoft.public.excel.misc
|
|||
|
|||
Compute string content
Function EvalCell(RefCell As String)
Application.Volatile EvalCell = Evaluate(RefCell) End Function Get rid of the quote marks then in a cell enter =evalcell(cellref) Your example returns 4.242640687 Gord Dibben MS Excel MVP On Sun, 13 Jan 2008 12:54:02 -0800, jfkaufeler wrote: How can I compute in a cell an expression string such as "sqrt(2)*(5-2)" ? |
#7
Posted to microsoft.public.excel.misc
|
|||
|
|||
Compute string content
Many thanks, it may solve my problem but I have not tried yet, regards,
"Gord Dibben" wrote: Function EvalCell(RefCell As String) Application.Volatile EvalCell = Evaluate(RefCell) End Function Get rid of the quote marks then in a cell enter =evalcell(cellref) Your example returns 4.242640687 Gord Dibben MS Excel MVP On Sun, 13 Jan 2008 12:54:02 -0800, jfkaufeler wrote: How can I compute in a cell an expression string such as "sqrt(2)*(5-2)" ? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Creating a text string by reading content in multiple cells | Excel Worksheet Functions | |||
How to transpose formulas from column content to row content. | Excel Worksheet Functions | |||
How do I insert content of a2 into text string in b2 and so on? | Excel Worksheet Functions | |||
How to import a text file to Excel treating all input content are in string. | Excel Discussion (Misc queries) | |||
how to evaluate the content of a string as if it was a formula | Excel Discussion (Misc queries) |