View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tushar Mehta Tushar Mehta is offline
external usenet poster
 
Posts: 1,071
Default VBA Macro for Solving Linear Equations

If you have the equations in matrix form, AX=B, then the solution is
X=A-inverse * B. XL supports matrix multiplication and inverse
operations. Suppose you have the A values in a range, say F2:G3 and
the B values in a column, say H2:H3. Then, select the appropriate
number of cells (2 in this case) in a column and array enter
=MMULT(MINVERSE(F2:G3),H2:H3)

--
An array formula is entered with CTRL-SHIFT-ENTER rather than just
ENTER. If done correctly, XL will display curly brackets { and }
around the formula

Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
Hello;

I've a number of sets of simultameous linear equations, with the number of
unknowns and no. of equations are equal in each set.
All the coefficients are to be read from a w/s. The values of the unknowns
are to be posted in a different w/s in the same w/b.
The number of unknowns in each set is less than 10. (In other words, not in
the 100s or the 1000s)

1. I'm a bit surprised that such relatively simple math. tool is not
included as a built=in feature in the Excel Analysis Tool. or, is it ?

2. It is likely that several VBA macros (w/code) do exist, but I've tried
100s of web sites and could not find what I'm looking for!

Could you please advise or refer me to a particular site ?

3. Alternatively, I do have a well-commented and very reliable (LU
Decomposition) FORTRAN Subroutine code (about 40 relatively simple
statements) that could possibly be converted (with your help!) to a VBA macro
for use in Excel (2003 Win XP).

I would very much appreciate your suggestion(s).

Thank you kindly.

(PS. I've already solved couple of sets manually, which could be used later
to validate the macro)