Converting a string into a formula
Posted: Mon Mar 16, 2009 7:03 am
Dear All,
I would like to know how I can convert a string into a formula (I guess this is how you would call it in Excel). I have a table with formulas in separate cells (for example in one cell I have 4+2*2) and now I want to have the outcome of the formulas in other cells (so in the former example 8).
So if you do the following, you get what I have now (I cannot think of a way that avoids getting the formulas as a string in a table):
Now I want cell (1,2) to give the outcome of the formula (so 8). I would initially think of something like this:
Since this is not possible, the question is: how to convert the string (formula) into a scalar (outcome of the formula)?
Some things that did not work:
1) @val option: it does not recognize the calculation symbols like +, -, etc.
2) tab01(1,2)="="+tab01(1,1). This does not convert the string into a value (although if you open the table, press edit and click on the cell it changes from “=4+2*2” into “8”. But this is not practical, since I have thousands of different formulas).
Any help is much appreciated!
I would like to know how I can convert a string into a formula (I guess this is how you would call it in Excel). I have a table with formulas in separate cells (for example in one cell I have 4+2*2) and now I want to have the outcome of the formulas in other cells (so in the former example 8).
So if you do the following, you get what I have now (I cannot think of a way that avoids getting the formulas as a string in a table):
Code: Select all
table tab01
%x="4+2*2"
tab01(1,1)=%x
Code: Select all
!y=tab01(1,1)
'(This is of course not possible: “string assigned to scalar”)
scalar z=!y
tab01(1,2)=z
Some things that did not work:
1) @val option: it does not recognize the calculation symbols like +, -, etc.
2) tab01(1,2)="="+tab01(1,1). This does not convert the string into a value (although if you open the table, press edit and click on the cell it changes from “=4+2*2” into “8”. But this is not practical, since I have thousands of different formulas).
Any help is much appreciated!