View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default use function to change a string to function's parameter

On Tue, 20 Nov 2007 23:27:01 -0800, ViestaWu wrote:

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