+ Reply to Thread
Results 1 to 4 of 4

solving 9 equations 9 unknowns in vba

  1. #1
    Registered User
    Join Date
    03-05-2014
    Location
    Iran
    MS-Off Ver
    Excel 2010
    Posts
    20

    Question solving 9 equations 9 unknowns in vba

    hi
    solving 9 equations 9 unknowns in vba With the following conditions:
    Example
    a11X1 +a12X2++a19X9 = b1
    a21X1 +a22X2++a29X9 = b2
    . . . . . . . . . . . . .
    a91X1 +a92X2++a99X9 = b9
    in Sheet 1
    a11 in Cell A1 and a12 in Cell B1 ...
    a21 in Cell A2 and a22 in Cell B2 ...
    .....
    .....


    in Sheet 2

    b1 in Cell A1
    b2 in Cell A2
    .....
    .....

    in Sheet 3
    (An important part of my question)
    solving 9 equations 9 unknowns Without using any formula, just press a button key(vba code)
    ---------------------------------------------
    Can someone help me,Tanks
    Last edited by Milade8080; 03-15-2014 at 07:26 AM.

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    13,317

    Re: solving 9 equations 9 unknowns in vba

    As this kind of has the feel of a homework problem, I don't want to give away too much and short circuit what you are supposed to learn from the exercise. On the other hand, I'm not certain what skills you are supposed to be learning from this.

    A few questions/observations before we delve into programming the solution.

    1) I find that I first need to understand the math behind a problem. Here's a tutorial on solving systems of linear equations: http://www.purplemath.com/modules/systlin6.htm Her tutorial focuses on the simpler 2 and 3 variable cases, but the concepts extend to 9 variables without modification. Wikipedia's page http://en.wikipedia.org/wiki/System_of_linear_equations may be useful because it has a section specifically discussing this in terms of matrix algebra.

    2) If you are going to use matrix algebra to solve these systems of equations (which ultimately leads to the question of how to code inverting a matrix), the next question will be about using Excel's built in MINVERSE() function. You've indicated that you cannot use the any worksheet function in the spreadsheet, are you likewise not allowed to call worksheet functions from VBA? If you are allowed to call Excel functions from VBA, then that becomes the heart of the problem http://msdn.microsoft.com/en-us/libr...ice.11%29.aspx If you are not allowed to call worksheet functions from VBA, then this becomes the more difficult problem of coding matrix inversion/Gaussian elimination. If this is about coding a matrix inversion algorithm from scratch, you will probably have to remind those of us who have not had to bother with this kind of coding for a long time exactly what that entails, so we can help you put those steps into VB/VBA specific syntax.

    3) Or perhaps you want to use something more like root finding algorithms (newton raphson for example) to solve these. As Excel already has the NR algorithm in the Solver utility, we will need to know if you are allowed to use the Solver utility or if you need to code your own NR/iterative algorithm. If you are allowed to use Solver, then this is mostly about how to call Solver from VBA (if you search, we already have many examples of how to do that). If you are not allowed to use Solver and you need to code an NR type algorithm from scratch, then, again, you will probably need to remind those of us who haven't had to do this for a long time of some of the detail of such a coding exercise, then we will better be able to help you put the algorithm into VBA specific syntax.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: solving 9 equations 9 unknowns in vba

    see attached example for 2 equations
    Attached Files Attached Files
    If solved remember to mark Thread as solved

  4. #4
    Valued Forum Contributor
    Join Date
    03-21-2013
    Location
    cyberia
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: solving 9 equations 9 unknowns in vba

    just for interest, and for the record

    gauss-jordan matrix inversion

    put a square nonsingular matrix - any size - in the current region of Range("A1"), and run the code

    linear equation solution is easy extension, although not really necessary to do the full inversion if equation solution is all that's needed
    Please Login or Register  to view this content.
    Last edited by kalak; 03-16-2014 at 06:21 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. solving equations
    By eng.green in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-19-2013, 09:19 AM
  2. solving equations
    By hmasenger in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-04-2011, 10:56 AM
  3. 10 unknowns using 10 simultaneous equations
    By j_cash777 in forum Excel General
    Replies: 4
    Last Post: 01-31-2010, 07:12 PM
  4. [SOLVED] solving for 2 unknowns using 2 simultaneous equations
    By elaturnas in forum Excel General
    Replies: 1
    Last Post: 02-08-2005, 04:06 PM
  5. solving for 3 unknowns using 3 simultaneous equations
    By elaturnas in forum Excel General
    Replies: 0
    Last Post: 02-08-2005, 02:06 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1