Sub topic 3
Goal Seek step by step
This chapter assumes you can write cell formulas and use absolute and relative references. It also assumes you know what operating profit and break-even mean. You don't need Solver yet. By the end you should be able to run Goal Seek on a small model, predict when it will refuse to work, and run the same search from VBA with a success check.
What Goal Seek does
A normal spreadsheet calculates forward. You type inputs and the formulas produce an output. Goal Seek reverses this. You name an output cell and the value you want it to reach, and Excel adjusts one input cell until the output matches.
Goal Seek has three fields:
| Field | Meaning | What it must be |
|---|---|---|
| Set cell | The cell whose value you want to control | A formula that depends, directly or through other cells, on the changing cell |
| To value | The target for the set cell | A number you type. It cannot be a cell reference |
| By changing cell | The input Excel will adjust | A cell holding a constant, not a formula |
Many Goal Seek failures come from breaking one of these three rules.
The model we will solve
Break-even is the sales volume at which operating profit is exactly zero. Build this small model on a sheet:
A1: Units sold B1: 1000
A2: Price per unit B2: 50
A3: Variable cost B3: 30
A4: Fixed costs B4: 15000
A5: Operating profit B5: =B1*(B2-B3)-B4The inputs are B1 through B4, and the only formula is B5. At 1,000 units, profit is 1000 × (50 − 30) − 15000 = 5,000. That is the forward calculation.
To work backward, ask: how many units make B5 equal zero? Algebra gives the answer, because 15000 ÷ 20 = 750. Goal Seek reaches the same answer without you rearranging the formula. That matters once the formula is too tangled to invert by hand.
Running Goal Seek
- Open the Data tab, choose What-If Analysis, then Goal Seek.
- Enter
B5in Set cell. - Enter
0in To value. - Enter
B1in By changing cell. - Click OK.
Excel shows a Goal Seek Status dialog that says whether it found a solution and displays the target and current values. Click OK to keep the result or Cancel to restore your original number.
Data > What-If Analysis > Goal Seek
Set cell: B5
To value: 0
By changing cell: B1After you accept, B1 contains 750 (possibly with a tiny rounding residue) and B5 shows 0 or a value very close to it.
What happens during the search
Excel does not solve the formula algebraically. It treats your model as a black box. It tries a value in B1, recalculates, looks at how far B5 is from the target, and chooses a better value. It repeats this until B5 is close enough or it runs out of attempts.
Two settings control the loop. You find them under File, Options, Formulas, in the Calculation options section:
- Maximum Iterations is the number of attempts. The default is 100.
- Maximum Change is the tolerance. The default is 0.001. Excel stops when the set cell is within this distance of the target value.
The tolerance applies to the set cell, not the changing cell. If your set cell is measured in millions, 0.001 is extremely tight, and Goal Seek may say it failed even though the answer is practically right. If your set cell is a small ratio such as 0.05, 0.001 is loose, and the answer can be visibly off. Chapter 5 returns to this. For now, treat the result as an approximation and inspect it.
Starting value matters
Because the search begins from whatever is in the changing cell, the starting value can change the outcome. In our linear model, any start works, since profit is a straight line in units. In a nonlinear model, such as an IRR-based valuation, different starts can lead to different answers or none at all.
If Goal Seek fails, try moving the changing cell to a sensible nearby value and run it again. A starting guess that is at least in the right order of magnitude helps.
Rules that cause failures
Check these before assuming Goal Seek is broken.
The changing cell must hold a constant
If B1 contained =D1*2, Goal Seek would show an error saying the cell must contain a value. Excel cannot overwrite a formula without destroying your model. Point the search at the underlying input instead, or temporarily replace the formula with a number.
The set cell must depend on the changing cell
If B5 does not trace back to B1, changing B1 has no effect and the search cannot move the output. This often happens with a broken link, a hardcoded number typed over a formula, or a changing cell on a different line of logic than you intended. Use Formulas, Trace Precedents on the set cell to confirm the link.
To value must be a typed number
You cannot type D10 in To value. If you need to hit a target that lives in another cell, type the number, or restructure the model. One common trick is to build a difference cell such as =B5-D10 and set that cell to 0.
The target must be reachable
Suppose you ask for profit of 5,000,000 and the changing cell is limited by logic elsewhere, for example a capacity cap built into the formula. No input can reach the target, and Goal Seek will report that it may not have found a solution.
The same problem occurs when the function has no zero. For instance, if costs always exceed revenue regardless of volume, no value of B1 produces zero profit.
Only one input moves
Goal Seek changes exactly one cell. If your target depends on price and volume together, you must fix one and solve for the other. Solving for several inputs at once is what Solver is for.
Reading the status dialog
The status message gives you information, so read it before clicking OK.
| Message | Meaning | What to do |
|---|---|---|
| Goal Seeking with Cell B5 may have found a solution | The set cell is within tolerance of the target | Check the changing cell for sense. Verify the result |
| Goal Seeking with Cell B5 may not have found a solution | The search stopped without meeting the tolerance | Change the starting value, loosen or tighten tolerance, or check the model |
| Cell must contain a value | The changing cell holds a formula | Replace the formula with an input |
| Reference must be to a single cell | You gave a range | Select one cell for each field |
Notice the word "may". Goal Seek never promises the answer is correct, only that its stopping rule was met.
Running Goal Seek from VBA
You can run the same search from a macro with Range.GoalSeek. The method returns True if Excel reports a solution and False otherwise. A macro that ignores the return value can leave an unsolved number in your model without telling anyone.
Sub SolveBreakEven()
Dim ok As Boolean
ok = Range("B5").GoalSeek(Goal:=0, ChangingCell:=Range("B1"))
If Not ok Then MsgBox "Goal Seek did not find a solution."
End SubA safer version restores the original input when the search fails:
Sub SolveBreakEvenSafely()
Dim original As Double
Dim ok As Boolean
original = Range("B1").Value
ok = Range("B5").GoalSeek(Goal:=0, ChangingCell:=Range("B1"))
If Not ok Then
Range("B1").Value = original
MsgBox "Goal Seek did not find a solution. Input restored."
End If
End SubHere Goal is the target value and ChangingCell is the input. The cell you call the method on is the set cell.
Checking the answer independently
Never accept a Goal Seek result without a second look. For this model, you can confirm it with a root-finding routine outside Excel. A root is a value of the input at which the function equals zero.
from scipy.optimize import brentq
def profit(units):
return units * (50 - 30) - 15000
break_even = brentq(profit, 0, 10000)
print(round(break_even, 2))This prints 750.0. The function brentq needs a bracket, meaning two inputs where profit has opposite signs. At 0 units profit is −15,000, and at 10,000 units it is +185,000, so a zero lies between them. Goal Seek has no bracket requirement, which is convenient but also means it cannot warn you that none exists.
A simpler check needs no code. Type the answer into B1 yourself, and confirm B5 shows zero. For a more demanding check, compute the closed form, fixed costs divided by contribution margin per unit, and compare.
Common mistakes
- Treating "found a solution" as proof. The tolerance may be too loose for your units.
- Forgetting the input is overwritten. Save a copy first or use Ctrl+Z.
- Pointing at a formula cell. Solve for the raw input, not a derived value.
- Hardcoding a number inside the formula. If
B5contained=B1*20-15000, changing price in B2 would no longer affect it, and the solved volume would silently be wrong. - Expecting a rounded answer. Results like 749.9999 are normal. Round them for presentation, not inside the model.
Exercise
In the break-even model, the fixed costs in B4 rise to 18,000. You run Goal Seek with Set cell B5, To value 0, By changing cell B1. What should B1 become, and what would happen if B1 contained the formula =D1*2 instead of a number?
Show answer
B1 should become 900, because 18000 ÷ (50 − 30) = 900. If B1 contained =D1*2, Excel would refuse to run the search with an error that the changing cell must contain a value, since it can only overwrite constants. You would solve for D1 (or whichever cell holds the underlying input) instead, and B1 would follow from its formula.
Exercise
Your macro calls Range("B5").GoalSeek(Goal:=0, ChangingCell:=Range("B1")) and then writes B1 into a report. Why is it risky not to check the return value, and what is one way to handle a False result?
Show answer
A False result means Excel stopped without meeting its tolerance or iteration rules, so B1 holds an unsolved intermediate value that the report would present as an answer. Handle it by saving the original B1 value before the call, restoring it when the call returns False, and showing a message or stopping the macro so no unsolved number reaches the report.