use function to change a string to function's parameter

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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!
 
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
 
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
 
Back
Top