The Solver in Excel data analysis package is used to perform what task select all that apply

To let the Excel Solver know which cells on the worksheet represent the decision variables, constraints and objective function, we click Solver button on the Excel Data tab, or the Premium Solver button on the Add-Ins tab, which displays the Solver Parameters dialog. In the Set Objective (or Set Target Cell) edit box, we type or click on cell F5, the objective function. In the By Changing Variable Cells edit box, we type B4:E4 or select these cells with the mouse. (Click on the image to see it full-size.)

The Solver in Excel data analysis package is used to perform what task select all that apply

To add the constraints, we click on the Add button in the Solver Parameters dialog and select cells F8:F11 in the Cell Reference edit box (the left hand side), and select cells G8:G11 in the Constraint edit box (the right hand side); the default relation <= is OK.  (Click on the image to see it full-size.)

The Solver in Excel data analysis package is used to perform what task select all that apply

We choose the Add button again (either from the Add Constraint dialog above, or from the main Solver Parameters dialog) to define the non-negativity constraint on the decision variables. (Alternatively, we can check the Make Unconstrainted Variables Non-Negative option in the Solver Parameters dialog.)

When we've completely entered the problem, the Solver Parameters dialog appears as shown below. This is the Excel Solver dialog from Excel 2010; the Solver in earlier versions of Excel have similar elements.  Frontline's Premium Solver products can emulate either style, and they also offer a new Ribbon-based user interface.  (Click on the image to see it full-size.) 

The Solver in Excel data analysis package is used to perform what task select all that apply

 

Finding and Using the Solution

To find the optimal solution, we simply click on the Solve button. After a moment, the Excel Solver returns the optimal solution in cells B4 through E4. This means that we should build 23 pallets of Tahoe panels, 15 pallets of Pacific panels, 39 pallets of Savannah panels, and 0 pallets of Aspen panels. This results in a total profit of $58,800 (shown in cell F5). (Click on the image to see it full-size.)

The Solver in Excel data analysis package is used to perform what task select all that apply

The message "Solver found a solution" appears in the Solver Results dialog, as shown above. (Click on the image to see it full size).  We now click on "Answer" in the Reports list box to produce an Answer Report, and click OK to keep the optimal solution values in cells B4:E4.

After a moment, the Solver creates another worksheet containing an Answer Report, like the one below, and inserts it to the left of the problem worksheet in the Excel workbook.  (Click on the image to see it full-size.)

The Solver in Excel data analysis package is used to perform what task select all that apply

This report shows the original and final values of the objective function and the decision variables, as well as the status of each constraint at the optimal solution. Notice that the constraints on glue, pressing, and pine chips are binding and have a slack value of 0. The optimal solution would use up all of these resources; however, there were 28,000 pounds of oak chips left over. If we could obtain additional glue, pressing capacity, or pine chips we could further increase total profits, but extra oak chips would not help in the short run.

There's a whole world beyond Excel Solver: Upgrade to Analytic Solver Basic and get greater solving power, wizards and Guided Mode, over 100 example models, extensive Help and user guides, access to our Solver.Academy courses, expert tech support -- plus Monte Carlo simulation and risk analysis, decision trees, data mining, text mining and machine learning, and more! It's an incredible offer, and you can try it for free.

Learn more about Analytic Solver Click Here

Learning More

If you've gotten to this point, congratulations! You've successfully set up and solved a simple optimization problem using Microsoft Excel.  If you'd like, you can see how to set up and solve the same Product Mix problem using Risk Solver Platform in Excel or using a Visual Basic .NET program that calls Frontline's Solver Platform SDK.  If you haven't yet read the other parts of the tutorial, you may want to return to the Tutorial Start and read the overviews "What are Solvers Good For?", "How Do I Define a Model?", "What Kind of Solution Can I Expect?" and "What Makes a Model Hard to Solve?"

This was an example of a linear programming problem.  Other types of optimization problems may involve quadratic programming, mixed-integer programming, constraint programming, smooth nonlinear optimization, and nonsmooth optimization.  To learn more, click Optimization Problem Types.  For a more advanced explanation of linearity and sparsity in optimization problems, continue with our Advanced Tutorial.

The tutorial explains how to add and where to find Solver in different Excel versions, from 2016 to 2003. Step-by-step examples show how to use Excel Solver to find optimal solutions for linear programming and other kinds of problems.

Everyone knows that Microsoft Excel contains a lot of useful functions and powerful tools that can save you hours of calculations. But did you know that it also has a tool that can help you find optimal solutions for decision problems?

In this tutorial, we are going to cover all essential aspects of the Excel Solver add-in and provide a step-by-step guide on how to use it most effectively.

What is Excel Solver?

Excel Solver belongs to a special set of commands often referred to as What-if Analysis Tools. It is primarily purposed for simulation and optimization of various business and engineering models.

The Excel Solver add-in is especially useful for solving linear programming problems, aka linear optimization problems, and therefore is sometimes called a linear programming solver. Apart from that, it can handle smooth nonlinear and non-smooth problems. Please see Excel Solver algorithms for more details.

While Solver can't crack every possible problem, it is really helpful when dealing with all kinds of optimization problems where you need to make the best decision. For example, it can help you maximize the return of investment, choose the optimal budget for your advertising campaign, make the best work schedule for your employees, minimize the delivery costs, and so on.

How to add Solver to Excel

The Solver add-in is included with all versions of Microsoft Excel beginning with 2003, but it is not enabled by default.

To add Solver to your Excel, perform the following steps:

  1. In Excel 2010 - Excel 365, click File > Options.
    In Excel 2007, click the Microsoft Office button, and then click Excel Options.
  2. In the Excel Options dialog, click Add-Ins on the left sidebar, make sure Excel Add-ins is selected in the Manage box at the bottom of the window, and click Go.
    The Solver in Excel data analysis package is used to perform what task select all that apply
  3. In the Add-Ins dialog box, check the Solver Add-in box, and click OK:
    The Solver in Excel data analysis package is used to perform what task select all that apply

To get Solver on Excel 2003, go to the Tools menu, and click Add-Ins. In the Add-Ins available list, check the Solver Add-in box, and click OK.

Note. If Excel displays a message that the Solver Add-in is not currently installed on your computer, click Yes to install it.

Where is Solver in Excel?

In the modern versions of Excel, the Solver button appears on the Data tab, in the Analysis group:

The Solver in Excel data analysis package is used to perform what task select all that apply

Where is Solver in Excel 2003?

After the Solver Add-in is loaded to Excel 2003, its command is added to the Tools menu:

The Solver in Excel data analysis package is used to perform what task select all that apply

Now that you know where to find Solver in Excel, open a new worksheet and let's get started!

Note. The examples discussed in this tutorial use Solver in Excel 2013. If you have another Excel version, the screenshots may not match your version exactly, although the Solver functionality is basically the same.

How to use Solver in Excel

Before running the Excel Solver add-in, formulate the model you want to solve in a worksheet. In this example, let's find a solution for the following simple optimization problem.

Problem. Supposing, you are the owner of a beauty salon and you are planning on providing a new service to your clients. For this, you need to buy a new equipment that costs $40,000, which should be paid by instalments within 12 months.

Goal: Calculate the minimal cost per service that will let you pay for the new equipment within the specified timeframe.

For this task, I've created the following model:

The Solver in Excel data analysis package is used to perform what task select all that apply

And now, let's see how Excel Solver can find a solution for this problem.

1. Run Excel Solver

On the Data tab, in the Analysis group, click the Solver button.

2. Define the problem

The Solver Parameters window will open where you have to set up the 3 primary components:

  • Objective cell
  • Variable cells
  • Constraints

Exactly what does Excel Solver do with the above parameters? It finds the optimal value (maximum, minimum or specified) for the formula in the Objective cell by changing the values in the Variable cells, and subject to limitations in the Constraints cells.

Objective

The Objective cell (Target cell in earlier Excel versions) is the cell containing a formula that represents the objective, or goal, of the problem. The objective can be to maximize, minimize, or achieve some target value.

In this example, the objective cell is B7, which calculates the payment term using the formula =B3/(B4*B5) and the result of the formula should be equal to 12:

The Solver in Excel data analysis package is used to perform what task select all that apply

Variable cells

Variable cells (Changing cells or Adjustable cells in earlier versions) are cells that contain variable data that can be changed to achieve the objective. Excel Solver allows specifying up to 200 variable cells.

In this example, we have a couple of cells whose values can be changed:

  • Projected clients per month (B4) that should be less than or equal to 50; and
  • Cost per service (B5) that we want Excel Solver to calculate.

The Solver in Excel data analysis package is used to perform what task select all that apply

Tip. If the variable cells or ranges in your model are non-adjacent, select the first cell or range, and then press and hold the Ctrl key while selecting other cells and/or ranges. Or, type the ranges manually, separated with commas.

Constraints

The Excel Solver Constrains are restrictions or limits of the possible solutions to the problem. To put it differently, constraints are the conditions that must be met.

To add a constraint(s), do the following:

  • Click the Add button right to the "Subject to the Constraints" box.

The Solver in Excel data analysis package is used to perform what task select all that apply

  • In the Constraint window, enter a constraint.
  • Click the Add button to add the constraint to the list.

The Solver in Excel data analysis package is used to perform what task select all that apply

  • Continue entering other constraints.
  • After you have entered the final constraint, click OK to return to the main Solver Parameters window.

Excel Solver allows specifying the following relationships between the referenced cell and the constraint.

  • Less than or equal to, equal to, and greater than or equal to. You set these relationships by selecting a cell in the Cell Reference box, choosing one of the following signs: <=, =, or >=, and then typing a number, cell reference / cell name, or formula in the Constraint box (please see the above screenshot).
  • Integer. If the referenced cell must be an integer, select int, and the word integer will appear in the Constraint box.
  • Different values. If each cell in the referenced range must contain a different value, select dif, and the word AllDifferent will appear in the Constraint box.
  • Binary. If you want to limit a referenced cell either to 0 or 1, select bin, and the word binary will appear in the Constraint box.

Note. The int, bin, and dif relationships can only be used for constraints on Variable cells.

To edit or delete an existing constraint do the following:

  • In the Solver Parameters dialog box, click the constraint.
  • To modify the selected constraint, click Change and make the changes you want.
  • To delete the constraint, click the Delete button.

In this example, the constraints are:

  • B3=40000 - cost of the new equipment is $40,000.
  • B4<=50 - the number of projected patients per month in under 50.

The Solver in Excel data analysis package is used to perform what task select all that apply

3. Solve the problem

After you've configured all the parameters, click the Solve button at the bottom of the Solver Parameters window (see the screenshot above) and let the Excel Solver add-in find the optimal solution for your problem.

Depending on the model complexity, computer memory and processor speed, it may take a few seconds, a few minutes, or even a few hours.

When Solver has finished processing, it will display the Solver Results dialog window, where you select Keep the Solver Solution and click OK:

The Solver in Excel data analysis package is used to perform what task select all that apply

The Solver Result window will close and the solution will appear on the worksheet right away.

In this example, $66.67 appears in cell B5, which is the minimal cost per service that will let you pay for the new equipment in 12 months, provided there are at least 50 clients per month:

The Solver in Excel data analysis package is used to perform what task select all that apply

Tips:

  • If the Excel Solver has been processing a certain problem for too long, you can interrupt the process by pressing the Esc key. Excel will recalculate the worksheet with the last values found for the Variable cells.
  • To get more details about the solved problem, click a report type in the Reports box, and then click OK. The report will be created on a new worksheet:

The Solver in Excel data analysis package is used to perform what task select all that apply

Now that you've got the basic idea of how to use Solver in Excel, let's have a closer look at a couple more examples that might help you gain more understanding.

Excel Solver examples

Below you will find two more examples of using the Excel Solver addin. First, we will find a solution for a well-known puzzle, and then solve a real-life linear programming problem.

Excel Solver example 1 (magic square)

I believe everyone is familiar with "magic square" puzzles where you have to put a set of numbers in a square so that all rows, columns and diagonals add up to a certain number.

For instance, do you know a solution for the 3x3 square containing numbers from 1 to 9 where each row, column and diagonal adds up to 15?

It's probably no big deal to solve this puzzle by trial and error, but I bet the Solver will find the solution faster. Our part of the job is to properly define the problem.

To begin with, enter the numbers from 1 to 9 in a table consisting of 3 rows and 3 columns. The Excel Solver does not actually need those numbers, but they will help us visualize the problem. What the Excel Solver add-in really needs are the SUM formulas that total each row, column and 2 diagonals:

The Solver in Excel data analysis package is used to perform what task select all that apply

With all the formulas in place, run Solver and set up the following parameters:

  • Set Objective. In this example, we don't need to set any objective, so leave this box empty.
  • Variable Cells. We want to populate numbers in cells B2 to D4, so select the range B2:D4.
  • Constraints. The following conditions should be met:
    • $B$2:$D$4 = AllDifferent - all of the Variable cells should contain different values.
    • $B$2:$D$4 = integer - all of the Variable cells should be integers.
    • $B$5:$D$5 = 15 - the sum of values in each column should equal 15.
    • $E$2:$E$4 = 15 - the sum of values in each row should equal 15.
    • $B$7:$B$8 = 15 - the sum of both diagonals should equal 15.

The Solver in Excel data analysis package is used to perform what task select all that apply

Finally, click the Solve button, and the solution is there!

The Solver in Excel data analysis package is used to perform what task select all that apply

Excel Solver example 2 (linear programming problem)

This is an example of a simple transportation optimization problem with a linear objective. More complex optimization models of this kind are used by many companies to save thousands of dollars each year.

Problem: You want to minimize the cost of shipping goods from 2 different warehouses to 4 different customers. Each warehouse has a limited supply and each customer has a certain demand.

Goal: Minimize the total shipping cost, not exceeding the quantity available at each warehouse, and meeting the demand of each customer.

Source data

Here is how our transportation optimization problem looks like:

The Solver in Excel data analysis package is used to perform what task select all that apply

Formulating the model

To define our linear programming problem for the Excel Solver, let's answer the 3 main questions:

  1. What decisions are to be made? We want to calculate the optimal quantity of goods to deliver to each customer from each warehouse. These are Variable cells (B7:E8).
  2. What are the constraints? The supplies available at each warehouse (I7:I8) cannot be exceeded, and the quantity ordered by each customer (B10:E10) should be delivered. These are Constrained cells.
  3. What is the goal? The minimal total cost of shipping. And this is our Objective cell (C12).

The next thing for you to do is to calculate the total quantity shipped from each warehouse (G7:G8), and the total goods received by each customer (B9:E9). You can do this with simple Sum formulas demonstrated in the below screenshot. Also, insert the SUMPRODUCT formula in C12 to calculate the total cost of shipping:

The Solver in Excel data analysis package is used to perform what task select all that apply

To make our transportation optimization model easier to understand, create the following named ranges:

Range name Cells Solver parameter
Products_shipped B7:E8 Variable cells
Available I7:I8 Constraint
Total_shipped G7:G8 Constraint
Ordered B10:E10 Constraint
Total_received B9:E9 Constraint
Shipping_cost C12 Objective

The last thing left for you to do is configure the Excel Solver parameters:

  • Objective: Shipping_cost set to Min
  • Variable cells: Products_shipped
  • Constraints: Total_received = Ordered and Total_shipped <= Available

The Solver in Excel data analysis package is used to perform what task select all that apply

Please pay attention that we've chosen the Simplex LP solving method in this example because we are dealing with the linear programming problem. If you are not sure what kind of problem yours is, you can leave the default GRG Nonlinear solving method. For more information, please see Excel Solver algorithms.

Solution

Click the Solve button at the bottom of the Solver Parameters window, and you will get your answer. In this example, the Excel Solver add-in calculated the optimal quantity of goods to deliver to each customer from each warehouse with the minimal total cost of shipping:

The Solver in Excel data analysis package is used to perform what task select all that apply

How to save and load Excel Solver scenarios

When solving a certain model, you may want to save your Variable cell values as a scenario that you can view or re-use later.

For example, when calculating the minimal service cost in the very first example discussed in this tutorial, you may want to try different numbers of projected clients per month and see how that affects the service cost. At that, you may want to save the most probable scenario you've already calculated and restore it at any moment.

Saving an Excel Solver scenario boils down to selecting a range of cells to save the data in. Loading a Solver model is just a matter of providing Excel with the range of cells where your model is saved. The detailed steps follow below.

Saving the model

To save the Excel Solver scenario, perform the following steps:

  1. Open the worksheet with the calculated model and run the Excel Solver.
  2. In the Solver Parameters window, click the Load/Save button.
    The Solver in Excel data analysis package is used to perform what task select all that apply
  3. Excel Solver will tell you how many cells are needed to save your scenario. Select that many empty cells and click Save:
    The Solver in Excel data analysis package is used to perform what task select all that apply
  4. Excel will save your current model, which may look something similar to this:

The Solver in Excel data analysis package is used to perform what task select all that apply

At the same time, the Solver Parameters window will show up where you can change your constraints and try different "what if" options.

Loading the saved model

When you decide to restore the saved scenario, do the following:

  1. In the Solver Parameters window, click the Load/Save button.
  2. On the worksheet, select the range of cells holding the saved model and click Load:
    The Solver in Excel data analysis package is used to perform what task select all that apply
  3. In the Load Model dialog, click the Replace button:
    The Solver in Excel data analysis package is used to perform what task select all that apply
  4. This will open the main Excel Solver window with the parameters of the previously saved model. All you need to do is to click the Solve button to re-calculate it.

Excel Solver algorithms

When defining a problem for the Excel Solver, you can choose one of the following methods in the Select a Solving Method dropdown box:

To change how Solver finds a solution, click the Options button in the Solver Parameters dialog box, and configure any or all options on the GRG Nonlinear, All Methods, and Evolutionary tabs.

This is how you can use Solver in Excel to find the best solutions for your decision problems. And now, you may want to download the Excel Solver examples discussed in this tutorial and reverse-engineer them for better understanding. I thank you for reading and hope to see you on our blog next week.

You may also be interested in