Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default urgent question: how to calculate value with a string formula

In Excel, I can get a string formula for some place.
for example: (P1+P2+P3^2)/3 , P1*2+P4/3, ........

P1, P2,P3,P4 is variant I can its value from some place:
for example: P1 = 1, P2 =2, P3 =3, P4 =4

so I can get the calculated formula as follow: "(1+2+3^2)/3"
my question is: how to convert this string formula to real calculate formula
? so I can get value (1+2+3^2)/3 is 4 ??

I have review all of function of string, can not find a way to do it:(
anyone can help me out ?? thanks a lot!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 618
Default urgent question: how to calculate value with a string formula

Hi

not sure i'm understanding you correctly
but
if you type
=(P1+P2+P3^2)/3
into a cell (with the =)
you will have a calulation that can be evaluated.

if this isn't what you're after please post back.
Regards
JulieD

"miao jie" wrote in message
...
In Excel, I can get a string formula for some place.
for example: (P1+P2+P3^2)/3 , P1*2+P4/3, ........

P1, P2,P3,P4 is variant I can its value from some place:
for example: P1 = 1, P2 =2, P3 =3, P4 =4

so I can get the calculated formula as follow: "(1+2+3^2)/3"
my question is: how to convert this string formula to real calculate

formula
? so I can get value (1+2+3^2)/3 is 4 ??

I have review all of function of string, can not find a way to do it:(
anyone can help me out ?? thanks a lot!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default urgent question: how to calculate value with a string formula

Sub Tester12()
sForm = "(P1+P2+P3^2)/3"
p1 = 2
p2 = 3
p3 = 4
p4 = 0
Debug.Print EvalFormula(p1, p2, p3, p4, sForm)
End Sub

Public Function EvalFormula(p1, p2, p3, p4, sForm)
Dim sForm1 As String
sForm1 = UCase(sForm)
sForm1 = Application.Substitute(sForm1, "P1", p1)
Debug.Print sForm1, p1
sForm1 = Application.Substitute(sForm1, "P2", p2)
sForm1 = Application.Substitute(sForm1, "P3", p3)
sForm1 = Application.Substitute(sForm1, "P4", p4)
EvalFormula = Evaluate(sForm1)
End Function

--
Regards,
Tom Ogilvy

"miao jie" wrote in message
...
In Excel, I can get a string formula for some place.
for example: (P1+P2+P3^2)/3 , P1*2+P4/3, ........

P1, P2,P3,P4 is variant I can its value from some place:
for example: P1 = 1, P2 =2, P3 =3, P4 =4

so I can get the calculated formula as follow: "(1+2+3^2)/3"
my question is: how to convert this string formula to real calculate

formula
? so I can get value (1+2+3^2)/3 is 4 ??

I have review all of function of string, can not find a way to do it:(
anyone can help me out ?? thanks a lot!



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
ANOTHER URGENT QUESTION - Sums and Ifs Michelle Excel Worksheet Functions 4 January 6th 12 06:46 PM
NEWSGROUP QUESTION URGENT Jonah Excel Worksheet Functions 8 November 5th 06 06:05 PM
How to find values in string? - Urgent! [email protected] Excel Discussion (Misc queries) 6 September 15th 06 02:12 PM
Simple Question but need urgent help pls... hendnov Excel Worksheet Functions 1 July 12th 06 02:13 PM
Urgent- Help ! (Message 'Calculate' Appears) Steve C. Excel Discussion (Misc queries) 2 August 17th 05 01:58 AM


All times are GMT +1. The time now is 04:35 AM.

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"