# solving equations

1. ## solving equations

Hi all ...
I need to know how I can solve an equation using excel macro
The equation is complex and have so much constants related to textboxes and cells .... and I will give a simple example
I have known values in column C and I need the values of Variable x ``Please Login or Register  to view this content.``  Register To Reply

2. ## Re: solving equations

I find that it is important to understand the math behind a problem before putting it into Excel. The equation is y=x(x-sin(x)), and we are trying to find the values for x at known y's. In mathematical terms, we will approach this using techniques for finding the roots or zeros of equations: http://en.wikipedia.org/wiki/Root-finding_algorithm So the first step is to re-write the equation so it is in a form z=f(x)-y=0

I need to know how I can solve an equation using excel macro
Does it have to be a macro?? The built in Solver utility will easily find the roots of equations (if you set up the spreadsheet correctly) without additional programming. If it has to be a macro, I see two approaches:

1) Call Solver from within VBA -- probably easiest to record a macro using the macro recorder while you call Solver manually. Then adapt the resulting code to your needs.

or
2) Write your own root finding algorithm (using one of the methods mentioned in Wikipedia). When I must do it in VBA, I will usually write my own algorithm, because I have found it easier to do that than to figure out the nuances of working with Solver from within VBA.  Register To Reply