Is there a function that will evaluate a text string in a cell?

D

Dave

Depending of the data in the spreadsheet, I need to change the formula in a
cell. I'm trying to find an excel function that will evaluate the resulting
text in a cell sort of like the INDIRECT() function does but one that will
work on formulas. I'm trying to use a formula in a cell to create a text
string that I then want evaluated. I.e.; a formula in cell A1 creates a text
string with a formula "=B2*C2". I'm looking for a function that will evaluate
that string. I thought this function was in excel but I can't find it.
 
J

Jacob Skaria

Try this UDF (User Defined function). From workbook launch VBE using Alt+F11.
From menu Insert a Module and paste the below function.Close and get back to
workbook and try the below formula.

In cellD2 you have the text
=B2*C2

In cell D3 you try the formula
=eval(D2)

Function Eval(strFormula As String) As Variant
Eval = Evaluate(strFormula)
End Function

If this post helps click Yes
 
A

Ashish Mathur

Hi,

Click on cell A1 and then go to Insert > Name > Define. Give it a name
called array. In the formula, enter =EVALUATE(Sheet1!$A$1). in A2, enter
=sum(array).

Hope this helps.

--
Regards,

Ashish Mathur
Microsoft Excel MVP
www.ashishmathur.com
 

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