+ Reply to Thread
Results 1 to 8 of 8

Solving for any blank variable from a formula

  1. #1
    Registered User
    Join Date
    02-21-2014
    Location
    PerryVille
    MS-Off Ver
    Excel 2007
    Posts
    3

    Solving for any blank variable from a formula

    I've tried searching for this but couldn't find anything that matched this problem.

    I'm trying to figure out a way to enter in a single formula, one which has been solved for zero. And have excel solve for any variable that has been left blank.

    So as a simple example take the equation "2X + 4Y - 8Z = 0"

    I would like to enter this formula into excel and then fill in two of the variables and have it solve for the third. So if I enter values for X and Y it gives me a value for Z. Or if I give it values for X and Z, it gives Y. And if given Y and Z it solves for X.

    Now this is a simple example, so I know it would be easy to rearrange the equation for each of the three variables and type all of them in to different cells. But the reason I would like to know if there's a way to do this is because I routinely deal with formula's that have 20 or more variables easily. I'd rather not have to rearrange that many times. It would be great to just solve for zero, plug that one equation in, have all my variables listed. Then whichever value i leave blank it solves for that unknown. As you can imagine with that many variables I've hesitated from even thinking about doing nested IF statements. I shudder at even trying to keep that straight.

    Is there any way that this can be done automatically in excel?

    And yes, i can do simple enough VBA (not a master of that, but I get by). So if that's an option I'd love to hear any ideas.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,049

    Re: Solving for any blank variable from a formula

    Hi and welcome to the forum

    I was starting to think that you could use an approach like this....

    =IF(A1="",formula to solve for that,IF(B1=0,formula to solve for that,formula to solve if C1=0)

    But that kinda got blown out of the water when you said you have 20+ variables (Might still be food for thought though?)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    02-21-2014
    Location
    PerryVille
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Solving for any blank variable from a formula

    Quote Originally Posted by FDibbins View Post
    Hi and welcome to the forum

    I was starting to think that you could use an approach like this....

    =IF(A1="",formula to solve for that,IF(B1=0,formula to solve for that,formula to solve if C1=0)

    But that kinda got blown out of the water when you said you have 20+ variables (Might still be food for thought though?)
    Yeah originally that was my thought too but I got a headache imagining writing that out. I'm a student in petroleum engineering and some of the equations we deal with in material balance of a reservoir can get a LOT of variables involved.

    So I was really hoping someone knew a simpler option. Heck even a VBA routine that could be called for different equations would be great.

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Solving for any blank variable from a formula

    goal seek will do it for one changing variable
    Attached Images Attached Images
    Last edited by martindwilson; 02-21-2014 at 10:07 PM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  5. #5
    Registered User
    Join Date
    02-21-2014
    Location
    PerryVille
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Solving for any blank variable from a formula

    Quote Originally Posted by martindwilson View Post
    goal seek will do it for one changing variable
    Thank you. I had been thinking of a formula based approach i could enter in a cell or a VBA solution. Hadn't considered Goal Seek. It's not automatic in that i would have to run it each time to solve for a different blank variable. But it does do it. So it's much better than IF statements for sure!

    If anyone has any other ideas for a different approach i'd still be interested.

  6. #6
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,454

    Re: Solving for any blank variable from a formula

    I'm sure it can be automated -- a lot depends on your programming skills (whether spreadsheet or other language), but none of the techniques are going to be pre-programmed into Excel for you.

    In some ways, Solver might be the easiest overall to work in. You will still need to either manually or programmatically identify the "missing" or "unkown" variables from the list of possible variables. Some kind of "linear programming" approach can be implemented with Solver to make this kind of problem relatively "simple."

    A lot of the time, "material balance" problems boil down to "solve a system of equations" type problems. If the variables are all "linear," you might be able to express the problem "simply" using matrix algebra, then use Excel's built in matrix functions (like MINVERSE() and MMULT()), along with an "identify the unkown variable" routine, to get to the solution. A lot of implementing this kind of solution will need to look at the actual equations that need solved, and whether you remember how to express them in matrix form.

    I have no doubt that this kind of problem can be solved in Excel. It is mostly about identifying and implementing an appropriate programming algorithm.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  7. #7
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Solving for any blank variable from a formula

    Pl see the attached file .I feel it satisfies all your needs.
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Solving for any blank variable from a formula

    With SUMPRODUCT formula also.
    Attached Files Attached Files

+ 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. [SOLVED] Solving for a Variable
    By andrewc in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-17-2014, 07:16 AM
  2. VBA code to fill blank cells with variable formula
    By Khen in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-08-2014, 08:24 AM
  3. Macro solving for missing variable
    By myfe in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-02-2012, 03:18 PM
  4. Solving for an exponential variable (x) of e
    By seanvalenzuela in forum Excel General
    Replies: 3
    Last Post: 03-23-2012, 02:10 PM
  5. Solving for variable for a formula equation = 0
    By WangDoodle in forum Excel General
    Replies: 2
    Last Post: 11-02-2008, 03:21 AM

Tags for this Thread

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