1

If I have cell A1 containing '6*2+8*5+7*4 and I want this calculation to execute in cell A2, so every time I change something in Cell A1 the value of cell A2 will change accordingly.

Community
  • 1
  • 1
Ben2014
  • 160
  • 11
  • possible duplicate of [Turn a string formula into a "real" formula](http://stackoverflow.com/questions/4471884/turn-a-string-formula-into-a-real-formula) – paul bica Sep 27 '15 at 23:23

2 Answers2

2

The Application.Evaluate method can take a string that looks like a foirmula and return a resolved result.

function eval_text(rng as range)
   eval_text = application.evaluate(rng.text)
end function

In B1 as =eval_text(A1) returns 80.

1

You can do it without VBA:

1

Open the Name Manager. Control-F3 from the worksheet, and then click the New button.

2

For the Name field in the dialog, enter EVALA. I just picked this name; it stands for "Evaluate A". But you can pick whatever name you like.

3

For the Refers to field, enter this

=EVALUATE($A1)

4

Click OK and then Close.

5

In B1 enter this formula:

=EVALA

That's it.

You can now use this formula on any row in the worksheet and it will evaluate whatever is in the column A cell of the row where you enter the formula.

Excel Hero
  • 14,253
  • 4
  • 33
  • 40
  • I don't think you can include the equals symbol inside the cell in this particular instance. The formula parser would not like the single apostrophe. – Excel Hero Sep 25 '15 at 14:10
  • 1
    True... but I often see that term used to describe a value entered with a prepended apostrohe in a cell that has the General number format applied. Perhaps OP can let us know what he meant. – Excel Hero Sep 25 '15 at 14:22