Convert Text to Formula

M

Mjones14

I have a cell with the text = sum(A10:A30) as the result of a formula. This
is because it is constructed by other formulae using values given by the user.

How do I evaluate this text as if it were a formula?
 
M

Mike H

Hi,

Post the formula that gave you this string as an output and it should be
possible to modify it it get the result you want.

Mike
 
J

Jacob Skaria

Should calculate and display the sum. Try formatting the cell to General and
edit (F2) and enter.
 
D

Dave Peterson

You'll need a user defined function.

Option Explicit
Function Eval(myStr As String) As Variant
Application.Volatile True
Eval = Application.Caller.Parent.Evaluate(myStr)
End Function


If you're new to macros:

Debra Dalgleish has some notes how to implement macros here:
http://www.contextures.com/xlvba01.html

David McRitchie has an intro to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm

(General, Regular and Standard modules all describe the same thing.)

Short course:

Open your workbook.
Hit alt-f11 to get to the VBE (where macros/UDF's live)
hit ctrl-R to view the project explorer
Find your workbook.
should look like: VBAProject (yourfilename.xls)

right click on the project name
Insert, then Module
You should see the code window pop up on the right hand side

Paste the code in there.

Now go back to excel.
Into a test cell and type:
=eval(a1)
 
T

T. Valko

Do you want to replace the original formula and convert the TEXT formula to
a working formula?

If so:

Select the cell(s) of interest
Goto Edit>Copy
Then, Edit>Paste Special>Values>OK

Then, Edit>Replace
Find what: =
Replace with: =
Replace all
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top