Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
ANOTHER URGENT QUESTION - Sums and Ifs | Excel Worksheet Functions | |||
NEWSGROUP QUESTION URGENT | Excel Worksheet Functions | |||
How to find values in string? - Urgent! | Excel Discussion (Misc queries) | |||
Simple Question but need urgent help pls... | Excel Worksheet Functions | |||
Urgent- Help ! (Message 'Calculate' Appears) | Excel Discussion (Misc queries) |