Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default Compute string content

How can I compute in a cell an expression string such as "sqrt(2)*(5-2)" ?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,651
Default Compute string content

Put this formula in the cell:
=SQRT(2)*(5-2)
and you should get a result like 4.242641
--
David Biddulph

"jfkaufeler" wrote in message
...
How can I compute in a cell an expression string such as "sqrt(2)*(5-2)" ?



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default Compute string content

Thank you for your prompt anwer. I didn't formulate my problem correctly.
What is in the cell is an expression string which was itself computed from
other cells (e.g. concatenation of different cell content (values and
operators).
Regards,

"David Biddulph" wrote:

Put this formula in the cell:
=SQRT(2)*(5-2)
and you should get a result like 4.242641
--
David Biddulph

"jfkaufeler" wrote in message
...
How can I compute in a cell an expression string such as "sqrt(2)*(5-2)" ?




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,059
Default Compute string content

On Jan 13, 12:54*pm, jfkaufeler
wrote:
How can I compute in a cell an expression string such as "sqrt(2)*(5-2)" ?


Not sure exactly what you mean.

First, do you actually have the quotes ("...") in the cell; or do you
have just the text without the quotes?

In either case, the "obvious" answer is: remove the quotes ("..."),
if they are present, and insert an equal sign (=) on the left. In
other words, manually turn the text into a formula.

But if what you mean is: you an expression as text in a cell, and in
another cell, you would like to evaluate the text as an Excel formula,
perhaps the following UDF would be helpful:

function doit(rng as Range)
s = replace(rng.value, chr(34), "")
doit = evaluate(s)
end function

Usage: If A1 contains the expression as text:

=doit(A1)

Note: The Replace() function call is needed only if you might have
explicit quotes in the string expression. If not, remove the "s="
line and "s" with rng.value in the Evaluate() function call.

Use alt+F11 and InsertModule to enter the text as in the VB Editor.
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default Compute string content

Many thanks, it looks to answer my question but I didn't have time to try.
Regards,

"joeu2004" wrote:

On Jan 13, 12:54 pm, jfkaufeler
wrote:
How can I compute in a cell an expression string such as "sqrt(2)*(5-2)" ?


Not sure exactly what you mean.

First, do you actually have the quotes ("...") in the cell; or do you
have just the text without the quotes?

In either case, the "obvious" answer is: remove the quotes ("..."),
if they are present, and insert an equal sign (=) on the left. In
other words, manually turn the text into a formula.

But if what you mean is: you an expression as text in a cell, and in
another cell, you would like to evaluate the text as an Excel formula,
perhaps the following UDF would be helpful:

function doit(rng as Range)
s = replace(rng.value, chr(34), "")
doit = evaluate(s)
end function

Usage: If A1 contains the expression as text:

=doit(A1)

Note: The Replace() function call is needed only if you might have
explicit quotes in the string expression. If not, remove the "s="
line and "s" with rng.value in the Evaluate() function call.

Use alt+F11 and InsertModule to enter the text as in the VB Editor.



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Compute string content

Function EvalCell(RefCell As String)
Application.Volatile
EvalCell = Evaluate(RefCell)
End Function

Get rid of the quote marks then in a cell enter =evalcell(cellref)

Your example returns 4.242640687


Gord Dibben MS Excel MVP

On Sun, 13 Jan 2008 12:54:02 -0800, jfkaufeler
wrote:

How can I compute in a cell an expression string such as "sqrt(2)*(5-2)" ?


  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default Compute string content

Many thanks, it may solve my problem but I have not tried yet, regards,

"Gord Dibben" wrote:

Function EvalCell(RefCell As String)
Application.Volatile
EvalCell = Evaluate(RefCell)
End Function

Get rid of the quote marks then in a cell enter =evalcell(cellref)

Your example returns 4.242640687


Gord Dibben MS Excel MVP

On Sun, 13 Jan 2008 12:54:02 -0800, jfkaufeler
wrote:

How can I compute in a cell an expression string such as "sqrt(2)*(5-2)" ?



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a text string by reading content in multiple cells smaruzzi Excel Worksheet Functions 3 February 8th 07 05:12 PM
How to transpose formulas from column content to row content. Notrom Excel Worksheet Functions 1 October 12th 06 06:57 PM
How do I insert content of a2 into text string in b2 and so on? Allenc Excel Worksheet Functions 1 August 6th 06 12:26 AM
How to import a text file to Excel treating all input content are in string. Chittu Excel Discussion (Misc queries) 1 July 22nd 05 06:37 AM
how to evaluate the content of a string as if it was a formula cyrille de brébisson Excel Discussion (Misc queries) 5 December 6th 04 10:47 PM


All times are GMT +1. The time now is 04:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"