Hello all and welcome back to the Excel Tip of the Week! This week, we have a Developer-level post and we're taking a fresh look at the advanced Goal Seek add-in, Solver. Solver was first covered in TOTW #116, and we revisited the simpler Goal Seek a few weeks ago in TOTW #250.
What is Solver and how do I install it?
Solver is an add-in that can find optimal solutions for problems described in Excel. It can quickly automate the process of trial-and-error to find solutions for complex problems with multiple constraints and multiple inputs. It is a powerful tool for skipping grunt work.
It's available for free and comes bundled with all Windows versions of Excel. To activate it:
Solver should then appear in the Data Ribbon.
How do I set up a scenario in Solver?
The most important thing is to carefully create your scenario and think it through so that you know what all the constraints you have to satisfy are, and they are all easy to express.
Here are some example constraints:
All of these are easy to transfer into Solver but must be carefully written beforehand.
Solver can find the maximum or minimum outcome for a given problem, or can find a set of inputs that lead to a given target outcome.
Once your scenario is all set up, we can then start to input it into Solver.
Above is the main Solver menu. Working from top to bottom:
Set Objective defines the single cell that will be monitored
To determines the goal that Solver will work towards
By changing variable cells defines which cell or range of cells Solver is allowed to manipulate in order to find its goal
Constraints allows you to set in any number of constraints - either constraints to the variable cells, or constraints elsewhere that the solution must satisfy
Constraints can apply to a cell or range of cells, and can refer either to a fixed constraint value or refer to a cell for a calculated or variable one. As well as constraints of being greater / equal / lesser to a value, you can also use the final three constraints: int (Integer, must be a whole number), bin (Binary, must be either 0 or 1), and dif (Different, must all be different).
Solving method and the associated Options menu lets you pick from the different algorithms that Solver might use - see the description shown in the box for guidance on how to pick one, but in most circumstances the method chosen won't matter too much.
When that's all done, hit Solve!
The outcome of running Solver
Solver can take a while to run depending on the complexity of your problem, so try to have a minimum of other files and programs running alongside it. Eventually, you will probably see the above dialog box show up. The values of your variable cells will have been changed to Solver's solution, and Solver will tell you how it got on. You can leave the values as Solver has suggested or go back and try other values. You can even save the outcome as a Scenario that you can easily return to later from the Scenario Manager.
Do remember that Solver isn't magic, and may not find a solution even if one exists - it is set to give up after a while rather than run forever. And your problem may not have a solution, for that matter!
Solver is something best tried out in practice, so open the file attached at the bottom of this post and give one of the practice scenarios a try.
Previous post - Power Query - Three-way matchingTOTW index Next post - A guide to common Excel file types
This blog is brought to you by the Excel Community where you can find additional blogs, extended articles and webinar recordings on a variety of Excel related topics. In addition to live training events, Excel Community members have access to a full suite of online training modules from Filtered. There is also an online forum where you can ask questions and share ideas with other community members.