IN THIS CHAPTER
The preceding chapter discussed what-if analysis — the process of changing input cells to observe the results on other dependent cells. This chapter looks at that process from the opposite perspective: finding the value of one or more input cells that produce a desired result in a formula cell.
Consider the following what-if question: “What is the total profit if sales increase by 20%?” If you set up your worksheet model properly, you can change the value in one or more cells to see what happens to the profit cell. The examples in this chapter take the opposite approach. If you know what a formula result should be, Excel can tell you the values that you need to enter in one or more input cells to produce that result. In other words, you can ask a question such as “How much do sales need to increase to produce a profit of $1.2 million?” Excel provides two tools that are relevant:
Single-cell goal seeking is a rather simple concept. Excel determines what value in an input cell produces a desired result in a formula cell. The following example shows you how single-cell goal seeking works.
Figure 36.1 shows the mortgage loan worksheet used in the preceding chapter. This worksheet has four input cells (C4:C7) and four formula cells (C10:C13). Originally, this worksheet was used for a what-if analysis example. This example demonstrates the opposite approach. Rather than supply different input cell values to look at the calculated formulas, this example lets Excel determine one of the input values that will produce the desired result.
Assume that you're in the market for a new home and you know that you can afford an $1,800 monthly mortgage payment. You also know that a lender can issue a 30-year fixed-rate mortgage loan for 6.50%, based on an 80% loan-to-value (that is, a 20% down payment). The question is: “What is the maximum purchase price I can handle?” In other words, what value in cell C4 (purchase price) causes the formula in cell C11 (monthly payment) to result in $1,800? In this simple example, you could plug values into cell C4 until C11 displays $1,800. With more complex models, Excel can usually determine the answer much more efficiently.
To answer the question posed in the preceding paragraph, first set up the input cells to match what you already know. Specifically:
Next, choose Data Forecast What-If Analysis Goal Seek. The Goal Seek dialog box appears. Completing this dialog box is similar to forming a sentence. You want to set cell C11 to 1800 by changing cell C4. Enter this information in the dialog box either by typing the cell references or by pointing with the mouse (see Figure 36.2). Click OK to begin the goal-seeking process.
In less than a second, Excel displays the Goal Seek Status box, shown in Figure 36.3, which shows the target value and the value that Excel calculated. In this case, Excel found an exact value. The worksheet now displays the found value in cell C4 ($355,974). As a result of this value, the monthly payment amount is $1,800. At this point, you have two options:
Excel can't always find a value that produces the result that you're seeking. Sometimes a solution simply doesn't exist. In such a case, the Goal Seek Status box informs you of that fact.
Other times, however, Excel may report that it can't find a solution, but you're pretty sure that one exists. If that's the case, you can try the following options:
The Excel Goal Seek feature is a useful tool, but it clearly has limitations. It can solve for only one adjustable cell, and it returns only a single solution. Excel's powerful Solver tool extends this concept by enabling you to do the following:
Although goal seeking is a relatively simple operation, using Solver can be much more complicated. In fact, Solver is probably one of the most difficult (and potentially frustrating) features in Excel. I'm the first to admit that Solver isn't for everyone. In fact, most Excel users have no use for this feature. However, many users find that having this much power is worth spending the extra time to learn about it.
Problems that are appropriate for Solver fall into a relatively narrow range. They typically involve situations that meet the following criteria:
After you set up your worksheet appropriately, you can use Solver to adjust the changing cells and produce the result that you want in your target cell — and simultaneously meet all the constraints that you defined.
I start with a simple example to introduce Solver and then present some increasingly complex examples to demonstrate what this feature can do.
Figure 36.4 shows a worksheet that is set up to calculate the profit for three products. Column B shows the number of units of each product, Column C shows the profit per unit for each product, and Column D contains formulas that calculate the total profit for each product by multiplying the units by the profit per unit.
You don't need an MBA to realize that the greatest profit comes from Product C. Therefore, to maximize total profit, the logical solution is to produce only Product C. If things were really this simple, you wouldn't need tools such as Solver. As in most situations, this company has some constraints that must be met:
These four constraints make the problem more realistic and a bit more challenging. In fact, it's a perfect problem for Solver.
I go into more detail in a moment, but here's the basic procedure for using Solver:
To start Solver to tackle this example, choose Data Analyze Solver. The Solver Parameters dialog box appears. Figure 36.5 shows this dialog box, set up to solve the problem.
In this example, the target cell is D6 — the cell that calculates the total profit for three products.
Table 37.1 Constraints Summary
Constraint | Expressed As |
Capacity is 300 units | B6=300 |
At least 50 units of Product A | B3>=50 |
At least 40 units of Product B | B4>=40 |
No more than 40 units of Product C | B5<=40 |
At this point, you have the following options:
The Reports section of the Solver Results dialog box lets you select any or all of three optional reports. If you specify any report options, Excel creates each report on a new worksheet, with an appropriate name. Figure 36.8 shows an Answer Report. In the Constraints section of the report, three of the four constraints are binding, which means that these constraints were satisfied at their limit with no more room to change.
This simple example illustrates the way Solver works. The fact is, you could probably solve this particular problem manually by trial and error. That, of course, isn't always the case.
Before presenting more complex examples, this section discusses the Solver Options dialog box. From this dialog box, you control many aspects of the solution process, as well as load and save model specifications in a worksheet range.
Usually, you want to save a model only when you're using more than one set of Solver parameters with your worksheet. This is because Excel saves the first Solver model automatically with your worksheet (using hidden names). If you save additional models, Excel stores the information in the form of formulas that correspond to the specifications. (The last cell in the saved range is an array formula that holds the options settings.)
It's not unusual for Solver to report that it can't find a solution, even when you know that one should exist. Often, you can change one or more of the Solver options and try again. When you click the Options button in the Solver Parameters dialog box, the Solver Options dialog box, shown in Figure 36.9, appears.
This list describes Solver's options:
The remainder of this chapter consists of examples of using Solver for various types of problems.
This example describes how to solve a set of three linear equations with three variables. Here's an example of a set of linear equations:
The question that Solver will answer is this: What values of x, y, and z satisfy all three equations?
Figure 36.10 shows a workbook set up to solve this problem. This workbook has three named cells, which makes the formulas more readable:
All three named cells are initialized to 1.0 (which certainly doesn't solve the equations).
The three equations are represented by formulas in the range B6:B8:
=(4*x)+(y)-(2*z)
=(2*x)-(3*y)+(3*z)
=-(6*x)-(2*y)+(z)
These formulas use the values in the x, y, and z named cells. The range C6:C8 contains the desired result for these three formulas.
Solver will adjust the values in x, y, and z — that is, the changing cells in C11:C13 — subject to these constraints:
B6=C6
B7=C7
B8=C8
Figure 36.11 shows the solution. The x (0.75
), y (–2.0
), and z (0.5
) values satisfy all three equations.
This example involves finding alternative options for shipping materials, while keeping total shipping costs at a minimum (see Figure 36.12). A company has warehouses in Los Angeles, St. Louis, and Boston. Retail outlets throughout the United States place orders, which the company then ships from one of the warehouses. The company wants to meet the product needs of all six retail outlets from available inventory and keep total shipping charges as low as possible.
This workbook is rather complicated, so I'll explain each part individually:
=SUMPRODUCT(C3:C8,D12:D17)
Cell G24 is the bottom line, the total shipping costs for all orders.
Solver fills in values in the range D12:F17 in such a way that minimizes shipping costs while still supplying each retail outlet with the desired number of units. In other words, the solution minimizes the value in cell G24 by adjusting the cells in D12:F17, subject to the following constraints:
C12=G12 C14=G14 C16=G16
C13=G13 C15=G15 C17=G17
D22>=0 E22>=0 F22>=0
Setting up the problem is the difficult part. For example, you must enter nine constraints. When you have specified all the necessary information, click the Solve button to put Solver to work. Solver displays the solution shown in Figure 36.13.
The total shipping cost is $55,515, and all the constraints are met. Notice that shipments to Miami come from both St. Louis and Boston.
The example in this section is a common type of problem that's ideal for Solver. Essentially, problems of this sort involve optimizing the volumes of individual production units that use varying amounts of fixed resources. Figure 36.14 shows a simplified example for a toy company.
This company makes five different toys, which use six different materials in varying amounts. For example, Toy A requires 3 units of blue paint, 2 units of white paint, 1 unit of plastic, 3 units of wood, and 1 unit of glue. Column G shows the current inventory of each type of material. Row 10 shows the unit profit for each toy.
The number of toys to make is shown in the range B11:F11. These are the values that Solver determines (the changing cells). The goal of this example is to determine how to allocate the resources to maximize the total profit (B13). In other words, Solver determines how many units of each toy to make. The constraints in this example are relatively simple:
Figure 36.15 shows the results that are produced by Solver. It shows the product mix that generates $12,365 in profit and uses all resources in their entirety, except for glue.
This example demonstrates how to use Solver to help maximize the return on an investment portfolio. A portfolio consists of several investments, each of which has a different yield. In addition, you may have some constraints that involve reducing risk and diversification goals. Without such constraints, a portfolio problem becomes a no-brainer: put all your money in the investment with the highest yield.
This example involves a credit union (a financial institution that takes members' deposits and invests them in loans to other members, bank CDs, and other types of investments). The credit union distributes part of the return on these investments to the members in the form of dividends, or interest on their deposits.
This hypothetical credit union must adhere to some regulations regarding its investments, and the board of directors has imposed some other restrictions. These regulations and restrictions comprise the problem's constraints. Figure 36.16 shows a workbook set up for this problem.
Allocating the $5 million portfolio is subject to these constraints:
C5>=C6*3
D14>=.15
E8<=.25
E9>=.10
The changing cells are C5:C9, and the goal is to maximize the total yield in cell D12. Starting values of 1,000,000 have been entered in the changing cells. When you run Solver with these parameters, it produces the solution shown in Figure 36.17, which has a total yield of 9.25%.