+ Reply to Thread
Results 1 to 21 of 21

Goal Seek and SOLVER

  1. #1
    Registered User
    Join Date
    04-14-2010
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    13

    Goal Seek and SOLVER

    Hi,

    I was wandering if anyone could help me.

    I am trying to get Excel to run a goal seek and a solver at the same time.

    In other words I need to program to run the solver for each itteration of the goal seek.

    Any ideas for a total programming novice?



    Thanks

    Dale Birrell

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Goal Seek and SOLVER

    Welcome to the forum.

    There's no need to use both; Solver can do anything Goal Seek can do, and more.

    You can record a macro applying Solver, clean up the code, and add a loop to compute as many results as necessary.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    04-14-2010
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Goal Seek and SOLVER

    Hi, thanks for the reply.

    However im sorry but im not sure i understand, perhaps i'll explain what im trying to do a little more clearly.

    I'll just use the names of the variables, their meanings are irrelevant.

    Im trying to use solver, to maximise drive by varying flat and twist, subject to the constraint RM = HM and the ranges that flat and twist lie in.

    Having maximised drive, i would then like to vary speed untill drive = resistance however both drive and resistance are a function of speed.

    So if you get what i mean, at each itteration of speed which will change both drive and resistance, i would like to maximise the drive, untill convergence.


    The only way i can get it to work so far is to goal seek the speed (for drive = resistance) and with the speed 'goal seeked' run the solver to get the maximised drive at that speed, which in turn, un balances the drive = resistance and hence a new speed is chosen. This process repeats itself for quite sometime before converging on the answer.

    Anyway, thanks again for the reply see what you can make of this

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Goal Seek and SOLVER

    Why not maximise drive by varying flat, twist, and speed, subject to the constraints on the ranges for flat and twist, RM = HM, and drive = resistance?

    EDIT: Maybe post a workbook?
    Last edited by shg; 04-16-2010 at 12:02 PM.

  5. #5
    Registered User
    Join Date
    04-14-2010
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Goal Seek and SOLVER

    Hi,

    I've tried what you suggested but Solver seems to ignore the drive = resistance constraint.

    I've attached the spreadsheet, all the variables are on the final page called 'solution'


    Thanks again
    Attached Files Attached Files

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Goal Seek and SOLVER

    There's a missing UDF (Spline) that's causing #NAME? errors throughout the workbook.

  7. #7
    Registered User
    Join Date
    04-14-2010
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Goal Seek and SOLVER

    Im not really sure, i've just opened the program on my laptop and it's fine.

    i'll re-attach it
    Attached Files Attached Files

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Goal Seek and SOLVER

    Spline is not a native function in Excel. You either have an add-in (like XlXtrFun.xll) or something in your Personal.xlsb. It's not in the workbook because xlsx files don't, by definition, contain macros.

  9. #9
    Registered User
    Join Date
    04-14-2010
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Goal Seek and SOLVER

    I see, yeh i've got XlXtrFun

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Goal Seek and SOLVER

    I added two formulas:

    Please Login or Register  to view this content.
    ... and created two models, then ran them alternately using some code I added, generating the result on the attachment. I have no idea if it's meaningful.

    If you want to run the code, you'll need to set a reference to Solver in the VBE:

    In the VBE, Tools > References, browse to C:\Program Files\Microsoft Office\OFFICExx\Library\SOLVER, change the file type dropdown to *.xls, *.xla, and pick SOLVER.XLA
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    04-14-2010
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Goal Seek and SOLVER

    The results you've posted there look pretty good, that's what i was lloking for,

    but when I open the attached file, cells D5 and D12 say #NAME?, and also when i check SOLVER in references, it comes up with "name conflict with existing module, project or object library."

  12. #12
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Goal Seek and SOLVER

    Post the version that gives you problems.

  13. #13
    Registered User
    Join Date
    04-14-2010
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Goal Seek and SOLVER

    here you go.
    Attached Files Attached Files

  14. #14
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Goal Seek and SOLVER

    Broken reference.
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    04-14-2010
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Goal Seek and SOLVER

    that's pretty much exactly what the doctor ordered!

    Is it possible to explain how you've written it?

    thanks a lot, that's a big help.

  16. #16
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Goal Seek and SOLVER

    The first model maximizes Drive while changing Twist and Flat with constraints 0<=Twist<=.45, 0<Flat<=0.8, and (RM-HM)^2<=0.1

    The second model minimizes (Drive-Resistance)^2 by changing Speed with the same constraints on Twist and Flat.

    Read about Solver in Help; all the code does is load the first model, solve, load the second, and solve. You can do the same thing from the UI using Load Model under Solver Options.

  17. #17
    Registered User
    Join Date
    04-14-2010
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Goal Seek and SOLVER

    thank you very much,

    much appreciation

  18. #18
    Registered User
    Join Date
    04-14-2010
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Goal Seek and SOLVER

    sorry, but how did you get rid of the prompt after solver runs asking you if you'd like to keep the solution?

  19. #19
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Goal Seek and SOLVER

    The UserFinish argument to SolverSolve.

  20. #20
    Registered User
    Join Date
    04-14-2010
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Goal Seek and SOLVER

    thanks a lot

  21. #21
    Registered User
    Join Date
    04-14-2010
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Goal Seek and SOLVER

    Hello again,

    I had to make some adjustments to the rest of the spreadsheet and tried to re-implement the code you had provided to run the two models but it wouldn't work. What was the reference to something in the excel folder in program files?

    If it's not too much trouble, could you possibly do it again?

    Im sorry, it's very lazy of me I really should get some books out and learn VB for myself but I just don't have the time just now.

    Thanks

    Dale
    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)

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