Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default Converting text to formulas

I am trying to streamline a mathematical optimization program that I wrote in
Excel with a macro. Say that I have typed a formula into cell A1 as a text
string, such as "x^2+10*x^4". Next I have renamed cell B5 as "x". I want
the cell C5 to convert the formula written as a text in A1 to the formula
"=x^2 +10*x^4" which will reference cell B5 and calculate it without having
to manually copy in the equation from A1.

I tried the Visual Basic Range.Formula= function but this only returns a
text. Substitute() and Text() do not seem to work either. Does anyone know
how to do this?
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 14
Default Converting text to formulas

try using INDIRECT()

Tieske

"Eutrapelia" wrote in message
...
I am trying to streamline a mathematical optimization program that I wrote
in
Excel with a macro. Say that I have typed a formula into cell A1 as a
text
string, such as "x^2+10*x^4". Next I have renamed cell B5 as "x". I want
the cell C5 to convert the formula written as a text in A1 to the formula
"=x^2 +10*x^4" which will reference cell B5 and calculate it without
having
to manually copy in the equation from A1.

I tried the Visual Basic Range.Formula= function but this only returns a
text. Substitute() and Text() do not seem to work either. Does anyone
know
how to do this?



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default Converting text to formulas

I tried using that, but it still only returns a text string, at least with
the way that I am using it.

"Tieske" wrote:

try using INDIRECT()

Tieske

"Eutrapelia" wrote in message
...
I am trying to streamline a mathematical optimization program that I wrote
in
Excel with a macro. Say that I have typed a formula into cell A1 as a
text
string, such as "x^2+10*x^4". Next I have renamed cell B5 as "x". I want
the cell C5 to convert the formula written as a text in A1 to the formula
"=x^2 +10*x^4" which will reference cell B5 and calculate it without
having
to manually copy in the equation from A1.

I tried the Visual Basic Range.Formula= function but this only returns a
text. Substitute() and Text() do not seem to work either. Does anyone
know
how to do this?




  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 14
Default Converting text to formulas

you're correct. INDIRECT only resolves a cell/range reference, not an entire
formula.

Ok, via VBA then. Try this macro:

Sub CalcFormula()
Dim myFormula As String
myFormula = Range("A4").Value
Range("C4").Formula = "=" & myFormula
End Sub

Create a button and hook it up to the macro. A4 contains your formula in
"plain text", C4 will have the calculated result.

Tieske

"Eutrapelia" wrote in message
...
I tried using that, but it still only returns a text string, at least with
the way that I am using it.

"Tieske" wrote:

try using INDIRECT()

Tieske

"Eutrapelia" wrote in message
...
I am trying to streamline a mathematical optimization program that I
wrote
in
Excel with a macro. Say that I have typed a formula into cell A1 as a
text
string, such as "x^2+10*x^4". Next I have renamed cell B5 as "x". I
want
the cell C5 to convert the formula written as a text in A1 to the
formula
"=x^2 +10*x^4" which will reference cell B5 and calculate it without
having
to manually copy in the equation from A1.

I tried the Visual Basic Range.Formula= function but this only returns
a
text. Substitute() and Text() do not seem to work either. Does anyone
know
how to do this?






  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,646
Default Converting text to formulas

See Evaluate Method in Excel Help!

Regards,
Stefi


€žEutrapelia€ť ezt Ă*rta:

I tried using that, but it still only returns a text string, at least with
the way that I am using it.

"Tieske" wrote:

try using INDIRECT()

Tieske

"Eutrapelia" wrote in message
...
I am trying to streamline a mathematical optimization program that I wrote
in
Excel with a macro. Say that I have typed a formula into cell A1 as a
text
string, such as "x^2+10*x^4". Next I have renamed cell B5 as "x". I want
the cell C5 to convert the formula written as a text in A1 to the formula
"=x^2 +10*x^4" which will reference cell B5 and calculate it without
having
to manually copy in the equation from A1.

I tried the Visual Basic Range.Formula= function but this only returns a
text. Substitute() and Text() do not seem to work either. Does anyone
know
how to do this?






  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 14
Default Converting text to formulas

yes! thats the one I meant. This should do it

"Stefi" wrote in message
...
See Evaluate Method in Excel Help!

Regards,
Stefi


"Eutrapelia" ezt írta:

I tried using that, but it still only returns a text string, at least
with
the way that I am using it.

"Tieske" wrote:

try using INDIRECT()

Tieske

"Eutrapelia" wrote in message
...
I am trying to streamline a mathematical optimization program that I
wrote
in
Excel with a macro. Say that I have typed a formula into cell A1 as
a
text
string, such as "x^2+10*x^4". Next I have renamed cell B5 as "x". I
want
the cell C5 to convert the formula written as a text in A1 to the
formula
"=x^2 +10*x^4" which will reference cell B5 and calculate it without
having
to manually copy in the equation from A1.

I tried the Visual Basic Range.Formula= function but this only
returns a
text. Substitute() and Text() do not seem to work either. Does
anyone
know
how to do this?





  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default Converting text to formulas

Thanks,

I was able to get it to work. It was a bit cumbersome, since I had to use
the Evaluate the function every time that the values changed, but it worked
well.

Jeremy

"Stefi" wrote:

See Evaluate Method in Excel Help!

Regards,
Stefi


€žEutrapelia€ť ezt Ă*rta:

I tried using that, but it still only returns a text string, at least with
the way that I am using it.

"Tieske" wrote:

try using INDIRECT()

Tieske

"Eutrapelia" wrote in message
...
I am trying to streamline a mathematical optimization program that I wrote
in
Excel with a macro. Say that I have typed a formula into cell A1 as a
text
string, such as "x^2+10*x^4". Next I have renamed cell B5 as "x". I want
the cell C5 to convert the formula written as a text in A1 to the formula
"=x^2 +10*x^4" which will reference cell B5 and calculate it without
having
to manually copy in the equation from A1.

I tried the Visual Basic Range.Formula= function but this only returns a
text. Substitute() and Text() do not seem to work either. Does anyone
know
how to do this?



  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Converting text to formulas

Can you use a UDF?

Function EvalCell(RefCell As String)
EvalCell = Evaluate(RefCell)
End Function

=EvalCell(A1) returns 2576


Gord Dibben MS Excel MVP

On Thu, 28 Sep 2006 22:13:01 -0700, Eutrapelia
wrote:

I am trying to streamline a mathematical optimization program that I wrote in
Excel with a macro. Say that I have typed a formula into cell A1 as a text
string, such as "x^2+10*x^4". Next I have renamed cell B5 as "x". I want
the cell C5 to convert the formula written as a text in A1 to the formula
"=x^2 +10*x^4" which will reference cell B5 and calculate it without having
to manually copy in the equation from A1.

I tried the Visual Basic Range.Formula= function but this only returns a
text. Substitute() and Text() do not seem to work either. Does anyone know
how to do this?


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
Converting numbers stored as dates to text in Excel David from Furdale Excel Discussion (Misc queries) 1 July 17th 06 06:34 PM
How to identify text from a autofiltered list using formulas Harryac Excel Worksheet Functions 1 July 13th 06 11:45 PM
need a refresher: text boxes on charts that use relational formulas? KR Charts and Charting in Excel 3 October 26th 05 03:08 PM
show text after formulas Shirley Excel Discussion (Misc queries) 3 June 30th 05 09:19 PM
Converting Numbers to Text properly Shirley Munro Excel Discussion (Misc queries) 1 February 16th 05 03:01 PM


All times are GMT +1. The time now is 06:10 AM.

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

About Us

"It's about Microsoft Excel"