# Thread: Convert String to Formula (XP SP3)

1. ## Convert String to Formula (XP SP3)

Hello everybody,

I am facing a new problem, from which I do not know whether there is a ready made solution already, or if I have to do it on my own. So here it is: Imagine you have a userform with a textfield where the user may enter an equation (e.g. "=0.5*(x-2)^2+2*x-3"). Naturally, I can access this equation as a text string and store it in a variable. I now need to find a way to convert it into an equation I can work with in my code. I know that I could use the Evaluate-command to get this solved for such relatively simple examples. Unfortunately, the formula can become much more complex, including a higher number of variables than only "x". I somehow need to find out what are the variables and how they are linked together. Has someone done s.th. like this before? Is there a built in function I yet did not recognize?

2. ## Re: Convert String to Formula (XP SP3)

Alternatively, try the free Power Calculator from Microsoft (Microsoft PowerToys for Windows XP). It can evaluate symbolic expressions.

Or get Maple or Mathematica

3. ## Re: Convert String to Formula (XP SP3)

Hello Hans,

thank you for the resources. It seems that the Math Expression Parser could be used (though it seems to handle more than I need ;-)). Unfortunately, the given alternatives aren't really ones, since I am bound to Excel for this task.
So thanks again!

4. ## Re: Convert String to Formula (XP SP3)

In that case, your alternative seems to be to write VBA code to parse the expression yourself. That is going to be a very complex undertaking. I would suggest that you start by finding a book/atricle on "Reverse Polish Notation". Wikipedia might be a good start.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•