Page 1 of 1
[Solved] Formula to number
Posted: Tue Feb 11, 2014 7:19 pm
by laco1234
Hello I want to ask you if there is a function to do following:
In first cell I have text string for example 2+8+3*5+2,35+7
In second cell a want to have result of calculation this string in first cell.
I don't want to change first cell and put "=" before string in first cell to calculate it there ....
Thank you a lot.
Re: formula to number
Posted: Tue Feb 11, 2014 7:35 pm
by Villeroy
menu:Insert>Names>Define...[ctrl+F3]
Enter some name, say F, and enter formula, click [Add] and [OK]
=F gives the result in any cell.
Re: formula to number
Posted: Tue Feb 11, 2014 8:21 pm
by laco1234
Thank you, but this is not what I need.
I have cell A1 that contains string - mathematical notation (numbers and operators) and I need another cell A2 that will refer to cell A1 and show result of A1.
So if I change notation in cell A1, it will automatically change result in A2.
So if I put to A1 text string 3+6+1 than A2 will show 10.
Re: formula to number
Posted: Tue Feb 11, 2014 8:27 pm
by MrProgrammer
Hi, and welcome to the forum.
laco1234 wrote:Hello I want to ask you if there is a function to do following: In first cell I have text string for example 2+8+3*5+2,35+7. In second cell a want to have result of calculation this string in first cell.
No. We
could have a function (presumably called EVAL) which evaluates a text string the same way that the formula processor would. If so, =EVAL("1+2") would be 3; or with A1 containing "SUM", =EVAL(A1&"(C4:C6)") would sum the numbers in C4 through C6.
However neither Calc nor any spreadsheet I'm familiar with has implemented an EVAL function.
But you can do the reverse. Type
=2+8+3*5+2,35+7 in the second
cell and use
=MID(FORMULA(cell);2;65535) in the first cell. When you change the second cell, the first one is automatically updated.
I suspect the following suggestion won't be "automatic" enough for you. If the text strings are in one column and you want the formulas in a second column you can use Edit > Copy on the first column, Edit > Paste on the second column and then, with the cells of the second column selected use Edit > Find & Replace > More options, select
Current selection only and
Regular Expressions, Search for
.*, Replace with
=&, Replace All. I recommend unchecking
Current selection only and
Regular expressions, before clicking Close. You can record a macro (Tools > Macros > Record) to perform these Copy/Paste/Replace steps. (I tested that.)
If this answered your question please go to your first post use the Edit button and add [Solved] to the start of the title. You can select the green checkmark icon at the same time.
Re: formula to number
Posted: Tue Feb 11, 2014 10:16 pm
by laco1234
thank you, I will try it.
Re: formula to number
Posted: Tue Feb 11, 2014 10:38 pm
by Villeroy
- EVAL.ods
- (10.4 KiB) Downloaded 268 times