Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to evaluate a string as a formula?

115 views
Skip to first unread message

zhaoni...@gmail.com

unread,
Mar 14, 2006, 9:44:12 PM3/14/06
to
Hi all,
I am going to write a string formula (without "=") in a cell, e.g.
(A1+B1)/2 in C1. And I want the cell C2 to display the value of the
formula in C1.
To be concrete, let's take an example as follows:
In a sheet, I write:
110 in A1,
90 in A2,
(A1+A2)/2 in C1.
What formula shall I write in cell C2 to get a value of 100, and get a
value of 50 when C1 is changed to (A1+A2)/4?
Thanks!

Raman

unread,
Mar 14, 2006, 11:10:53 PM3/14/06
to
Be more specific
You could enter the same formula
It is not possible in excel to write a function without =
You could use the tools-options-transition-transition formula entry
option to use excel as a virtual calculator

Ron Rosenfeld

unread,
Mar 15, 2006, 1:30:36 AM3/15/06
to
On 14 Mar 2006 18:44:12 -0800, "zhaoni...@gmail.com"
<zhaoni...@gmail.com> wrote:

You will need to use VBA in order to do this.

<alt-F11> opens the VB Editor.

Ensure your project is highlighted in the project explorer window, then select
Insert/Module from the top menu and enter the code below into the window that
opens.

Then, in C2, enter the formula: =Eval(C1)

=====================
Function Eval(rg As Range)
Application.Volatile
Eval = Evaluate(rg.Text)
End Function
======================

--ron

bplu...@gmail.com

unread,
Mar 15, 2006, 10:25:23 AM3/15/06
to
Hello,

you might want to use the VBA function EVAL() shown at
http://www.decisionmodels.com/calcsecretsh.htm

Another approach is shown at
http://www.sulprobil.com/html/it_quality.html

HTH,
Bernd

zhaoni...@gmail.com

unread,
Mar 19, 2006, 10:23:40 PM3/19/06
to
Thanks, I think the method you provided is exactly what I want. But
when I did it that way, it showed me a "#NAME?" in C2. What's the
problem?

Peo Sjoblom

unread,
Mar 19, 2006, 10:33:18 PM3/19/06
to
Did you do this part?

"You will need to use VBA in order to do this.

<alt-F11> opens the VB Editor.

Ensure your project is highlighted in the project explorer window, then
select
Insert/Module from the top menu and enter the code below into the window
that
opens."

--

Regards,

Peo Sjoblom

Northwest Excel Solutions

www.nwexcelsolutions.com

(remove ^^ from email address)

Portland, Oregon


<zhaoni...@gmail.com> wrote in message
news:1142825020....@t31g2000cwb.googlegroups.com...

Ron Rosenfeld

unread,
Mar 19, 2006, 10:41:57 PM3/19/06
to
On 19 Mar 2006 19:23:40 -0800, "zhaoni...@gmail.com"
<zhaoni...@gmail.com> wrote:

Post back, by copying exactly (Edit/Copy) exactly what you entered into the VB
Editor and exactly what you entered as a formula.


--ron

zhaoni...@gmail.com

unread,
Mar 21, 2006, 1:29:09 AM3/21/06
to
In VBA module, I wrote(actually copied your code):

Function Eval(rg As Range)
Application.Volatile
Eval = Evaluate(rg.Text)
End Function

In the worksheet, cell C1, I wrote:
(A1+A2)/2

In cell C2, I wrote:
=eval(C1)

And I am sure that the VBA module is under the same project with the
workbook.

TKT-Tang

unread,
Mar 21, 2006, 1:49:07 AM3/21/06
to
Have you not referred to the (ubiquitous) EEE letters located at
J-Walk's Excel web-site ?

Regards.

zhaoni...@gmail.com

unread,
Mar 21, 2006, 2:07:09 AM3/21/06
to
J-Walk's Excel web-site?
Where is it?

TKT-Tang

unread,
Mar 21, 2006, 2:56:54 AM3/21/06
to

zhaoni...@gmail.com wrote:
> J-Walk's Excel web-site ?
> Where is it ?

I see ; J-Walk is not his real name previously. But nowadays, he is
running a blog by that name. That shows that he likes the name.

Please visit the following link (to start with, and then, one may wish
to proceed further) :-

http://j-walk.com/ss/books/index.htm

Please do so today and thereafter, everyday ; any time of the day,
well, almost. That's a pilgimage to the Mecca of Excel (You won't mind,
Mr. Walker ?).

Regards.

0 new messages