GoalSeek Method

Applies To

Range Object.

Description

Calculates the values necessary to achieve a specific goal. If the goal is an amount returned by a formula, this calculates a value that, when supplied to your formula, causes the formula to return the number you want. Returns True if the goal seek is successful.

Syntax

object.GoalSeek(goal, changingCell)

object

Required. The specified range must be a single cell.

goal

Required. The value you want returned in this cell.

changingCell

Required. A Range object indicating which cell should be changed to achieve the target value.

Example

This example assumes that Sheet1 has a cell named "Polynomial" containing the formula =(X^3)+(3*X^2)+6 and another cell named "X" that is empty. The example finds a value for X so that Polynomial contains the value 15.


Worksheets("Sheet1").Range("Polynomial").GoalSeek _
    goal:=15, _
    changingCell:=Worksheets("Sheet1").Range("X")