Excel Goal Seek Formula: How to Loop It

Formulas & functions · Updated November 21, 2026

Excel does not have a worksheet function called LOOP or GOALSEEK: Goal Seek is a built-in What-If Analysis command, and it solves one input at a time. To repeat the process for many rows, use a VBA loop that calls Goal Seek for each row; for a single calculation, use Data > What-If Analysis > Goal Seek.

Why There Is No Goal Seek Formula

A normal Excel formula calculates a result from its inputs. Goal Seek works in the opposite direction: you supply the result you want, and Excel changes one input cell until a formula cell reaches that result. Because it is an analysis tool rather than a worksheet function, you cannot type a function such as GOALSEEK into a cell and expect Excel to solve for an input.

That distinction matters when someone asks for a “loop goal seek formula.” A formula cannot repeatedly change other cells as a loop would. You can use the Goal Seek dialog for one case, or automate repeated cases with VBA. If the calculation can be rearranged algebraically, an ordinary formula may be simpler; if it cannot, Goal Seek or another optimization tool is more appropriate.

How Goal Seek Works for One Calculation

Goal Seek needs three things: a formula cell to set, a target value, and one cell that Excel is allowed to change. The formula cell must depend, directly or indirectly, on the changing cell. In Microsoft Excel for Microsoft 365 on Windows, open Data > What-If Analysis > Goal Seek, then fill in the dialog fields:

  1. Set cell: Choose the cell containing the formula whose result you want to reach.
  2. To value: Enter the desired result as a number.
  3. By changing cell: Choose the single input cell Excel may adjust.

Select OK to let Excel search for a solution. The resulting value is written into the changing cell. Excel then displays the Goal Seek Status dialog; accept the result to keep it, or cancel to restore the earlier value. Goal Seek changes a value, not the formula in the set cell.

A Simple Example with a Formula

Suppose A2 contains a starting estimate and B2 calculates a value that is 8% higher. With the input in A2 and the calculated output in B2, enter this formula in B2:

=A2*1.08

To make B2 equal 150, use B2 as the Set cell, enter 150 as the target, and choose A2 as the changing cell. The solution is about 138.8889, because 138.8889 multiplied by 1.08 is approximately 150. If you format A2 as a whole number, the displayed value may be rounded even though the stored value has decimals. Set an appropriate number format before judging whether a result is accurate enough.

This example also shows why a formula alone is not the same as Goal Seek. The formula calculates the output from A2; Goal Seek searches for the A2 value that produces the target output. If you can isolate the input with algebra, you can calculate it directly, but Goal Seek is useful when the formula is longer, nonlinear, or inconvenient to rearrange.

Looping Goal Seek Across Multiple Rows

For repeated cases, organize the worksheet so each row has its own changing input, formula result, and target. For example, use column A for the input, column B for the result formula, column C for the target result, and column D for a status message. Put headers in row 1 and case data in rows 2 through 6. Each B-row formula should refer to the A cell on the same row, and each target should be in the matching C cell.

With the input in A2 and the calculated result in B2, enter this example formula in B2, then fill it down through the case rows:

=A2*1.08

A loop can then tell Excel to set B2 to C2 by changing A2, set B3 to C3 by changing A3, and continue down the list. The target does not have to be the same for every row. This is often the practical meaning of “loop Goal Seek”: apply the same solve operation to a series of independent scenarios, rather than trying to create a special worksheet formula.

VBA Macro for Repeated Goal Seek

The following example assumes a worksheet named Model, a formula in column B, target values in column C, changing inputs in column A, and status output in column D. It processes rows 2 through the last row with a value in column C. It skips rows where B has no formula or C is not numeric.

Sub GoalSeekEachRow()
    Dim ws As Worksheet
    Dim lastRow As Long
    Dim r As Long
    Dim solved As Boolean

    ' Use the worksheet that contains the scenarios.
    Set ws = ThisWorkbook.Worksheets("Model")
    lastRow = ws.Cells(ws.Rows.Count, "C").End(xlUp).Row

    ' Solve each row using its target and input cells.
    For r = 2 To lastRow
        If ws.Cells(r, "B").HasFormula And IsNumeric(ws.Cells(r, "C").Value) Then
            solved = ws.Cells(r, "B").GoalSeek( _
                Goal:=CDbl(ws.Cells(r, "C").Value), _
                ChangingCell:=ws.Cells(r, "A"))

            If solved Then
                ws.Cells(r, "D").Value = "Solved"
            Else
                ws.Cells(r, "D").Value = "Goal Seek did not converge"
            End If
        End If
    Next r
End Sub

To use it in Excel for Microsoft 365 on Windows, open the Visual Basic Editor with Alt+F11, choose Insert > Module, and paste the code into the module. Change the sheet name and column references if your layout differs. Run the macro with Alt+F8 and select GoalSeekEachRow. On a Mac, the Visual Basic Editor is available in Excel, and the Option+F11 shortcut may require the Fn key depending on the keyboard; VBA macros are not available in Excel for the web.

Save a copy of the workbook before running the macro. Save a macro-enabled workbook as .xlsm if you need to retain its VBA code, and only enable macros from sources you trust. Macro changes cannot be undone with Ctrl+Z, so the backup is important. The status in column D reports whether Goal Seek returned success, but it does not replace checking whether the result makes sense for the model.

Common Problems and Ways to Fix Them

A failed or unexpected result usually points to the model setup or to the limits of solving for a single input. Check these issues before changing the macro:

  • The set cell is not a formula. Goal Seek needs a formula result to adjust. Confirm that the selected cell contains a formula, not a hard-coded value.
  • The formula does not depend on the changing cell. If changing A2 cannot affect B2, Excel has no route to the requested target. Check the formula references, including references hidden inside other calculations.
  • The target is unreachable. For example, a formula may have a maximum or minimum output that excludes the requested value. A non-converged result is not proof that a nearby value is correct.
  • The starting value is a poor guess. For nonlinear formulas, a different initial input can lead to a different solution or make a solution harder to find. Try a plausible starting value and inspect the resulting formula.
  • The answer is sensitive to rounding or discontinuities. Rounded formulas, lookup-based steps, and IF conditions can create flat regions or jumps. A smooth formula is generally easier to solve than one with abrupt changes.
  • The rows are not independent. If one row’s formula depends on another row’s changing input, solving sequentially may affect earlier results. Design the order deliberately or use a model that accounts for the dependencies.

Goal Seek is designed around one changing cell per solve. It does not let you set bounds such as “input must be at least zero” in the dialog, nor does it impose several constraints. Check the final input and output against the real-world limits of the problem rather than assuming any returned number is valid.

Goal Seek, Solver, and Iterative Calculation

Goal Seek is a good fit when one formula output must reach one numeric target by changing one input. Use Solver when a problem involves multiple changing cells or constraints, such as requiring a value to be nonnegative while maximizing an objective. Solver is an Excel add-in; if it is not available, enable the Solver Add-in through Excel’s add-in settings. Its availability and interface can vary by platform.

Iterative calculation is different again. Excel’s iterative calculation setting allows formulas with circular references to recalculate repeatedly, subject to iteration limits. It does not provide a convenient substitute for a loop of independent Goal Seek operations, and turning it on can make a workbook harder to understand. Do not create a circular reference merely to imitate Goal Seek unless the model genuinely requires one and you understand how its iteration settings affect the result.

If every result can be calculated directly, ordinary formulas are usually easier to audit and recalculate than a macro. If the model has several variables and constraints, Solver is usually the closer tool. If you need to solve the same one-variable target repeatedly across a table, VBA calling Goal Seek is a practical middle ground.

Excel for Mac and Excel for the Web

In desktop Excel for Mac, Goal Seek is generally available from Data > What-If Analysis > Goal Seek, though the ribbon layout can differ slightly from Windows. Excel for the web does not run VBA macros; use desktop Excel to run the loop. If a web version does not show the Goal Seek command in its current interface, open the workbook in the desktop app rather than relying on a formula that Excel does not provide.

Frequently Asked Questions

Is there a GOALSEEK function in Excel?
No. Goal Seek is a command under Data > What-If Analysis, not a built-in worksheet function. Use VBA to repeat the command automatically.

Can I use Goal Seek for several cells at once?
The Goal Seek dialog solves one set cell by changing one input cell at a time. A VBA loop can repeat that operation across rows, while Solver is the better choice when one model needs multiple adjustable cells or constraints.

Why does Goal Seek return a different answer from what I expected?
Check the target, formula references, starting input, and number format. Nonlinear formulas can have more than one possible solution, and a displayed rounded number may differ from the underlying value.

Can I loop Goal Seek without VBA?
You can run Goal Seek manually for each row, but Excel does not provide a worksheet formula that loops through Goal Seek cases. If the math can be rearranged, direct formulas can calculate each input without automation.

Does Goal Seek work in Excel for the web?
VBA macros do not run in Excel for the web. For a repeated VBA solution, open the workbook in desktop Excel; the Goal Seek command itself may also depend on the web app’s available features.

Related

Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.

More in Formulas & functions

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.