There are lots of options that can be set in solver in VBA, which are set using a number of commands. Either play around with "record macro" to see what VBA writes, or look in the help system (make sure you are looking in "Microsoft Excel Visual Basic Help", rather than the general VBA help that sometimes come up in the VB editor as a default)
SolverOk is used to set the basic parameters, so that e.g.
sets all of the various options (you'll have to look in the help for the meaning of all these, usually you can just omit the statement completely)
and
SolverSolve Userfinish:=True
actually runs the thing. The userfinish:=True is so that the macro doesn't need to stop to tell me what it's done and then wait for me to say OK.
One little hiccup - if you do a record macro, you may find that solver works fine when you do it in Excel, but the macro keeps falling over with a "Sub or Function not defined" error. This is because the solver add-in to VBA is separate from the solver add-in to VBA. To get the VBA version to run, you need to go into the menu tools/references and tick the "solver.xls" option.
Hope this helps a little - as I say you'll to experiment a bit to get exactly what you want. (Have fun!)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.