ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   use function to change a string to function's parameter (https://www.excelbanter.com/excel-worksheet-functions/166865-use-function-change-string-functions-parameter.html)

ViestaWu

use function to change a string to function's parameter
 
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!

Mike H

use function to change a string to function's parameter
 
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


"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!


ViestaWu

use function to change a string to function's parameter
 
when A1 must be 1+1(text), do you have some idea?
and this is why I try b1="="&a1.

"Mike H" wrote:

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


"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!


Ron Rosenfeld

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


All times are GMT +1. The time now is 09:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com