Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

treating text as formula

Status
Not open for further replies.

riskassure

Programmer
May 6, 2005
33
US
Hi,

I have the following problem: in cell A1, I typed "B1+B2". In cell A2, I want to convert the text in A1 into a formula and then calculate that formula.

So if B1 = 5 and B2 = 6, A2 should read 11, and if B1 = 3 and B2 = -1, A2 should return 2.

Of course, I could have just use the formula '=B1+B2' in A2 and get a direct answer. But what I really want to do is much more complicated than the simple example I gave above.

Question: is there a way to do this without resorting to VBA? I tried putting

=Indirect(A1)

But that failed.. and gave me a ref# error.

Any help will be greatly appreciated!

~~CW~~
 



Hi,

Check out GlennUK's solution in thread68-1538709.

Skip,
[sup][glasses]Don't let the Diatribe...
talk you to death![tongue][/sup][sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Thanks! In the post, it mentioned a function called Evaluate, which is not available in Excel 2003, so what I ended up doing is to create a user defined function called Eval:

Function Eval(x as string)

Eval = Application.Evaluate(x)

End Function

And this works just as well!

~~CW~~
 

riskassure

It is definitely available in Excel 2003 - if you use it as it is described in that thread - through defining a name, and not directly in the cell.

But using a UDF is another way of doing it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top