use function to change a string to function's parameter

V

ViestaWu

Dear all,

If A1 is "1+1", I want to get the result in B1, how to do?

I have try B1=A1, doesn't work. B1="="&A1, doesn't work. B1="="&A1 +0, reply
value error.

I need your suggestion.
Thanks!
 
M

Mike H

A couple of points.

1+1 in A1 will end up as text i.e. it will show "1+1" in the cell. If you
want the sum 1+1 then the correct way to do it is to type

=1+1

The correct formula for B1 is simply

=A1

Mike
 
V

ViestaWu

when A1 must be 1+1(text), do you have some idea?
and this is why I try b1="="&a1.
 
R

Ron Rosenfeld

Dear all,

If A1 is "1+1", I want to get the result in B1, how to do?

I have try B1=A1, doesn't work. B1="="&A1, doesn't work. B1="="&A1 +0, reply
value error.

I need your suggestion.
Thanks!

You will need to use VBA to write a simple UDF (user defined function) to do
this.

To enter the function, <alt-F11> opens the VB Editor.
Ensure your project is highlighted in the Project Explorer window, then
Insert/Module and paste the code below into the window that opens.

To use this, enter the formula

B1: =Eval(A1)

==================================
Function Eval(str As String)
Eval = Evaluate(str)
End Function
=========================
--ron
 
Top