﻿ GoalSeek Method (IRange)
GoalSeek Method (IRange)

 SpreadsheetGear Namespace > IRange Interface : GoalSeek Method
Specifies the desired goal from the calculated result of the formula in the cell represented by this IRange.
Specifies the cell to change.
Attempts to achieve the specified goal, from the calculated result of the formula in the cell represented by this IRange, by modifying the specified changingCell using a simple iterative linear search.
Syntax
```'Declaration

Function GoalSeek( _
ByVal goal As System.Double, _
ByVal changingCell As IRange _
) As System.Boolean```
```'Usage

Dim instance As IRange
Dim goal As System.Double
Dim changingCell As IRange
Dim value As System.Boolean

value = instance.GoalSeek(goal, changingCell)```
```System.bool GoalSeek(
System.double goal,
IRange changingCell
)```
```function GoalSeek(
goal: System.Double;
changingCell: IRange
): System.Boolean; ```
```function GoalSeek(
goal : System.double,
changingCell : IRange
) : System.boolean;```
```System.bool GoalSeek(
System.double goal,
IRange* changingCell
) ```
```System.bool GoalSeek(
System.double goal,
IRange^ changingCell
) ```

#### Parameters

goal
Specifies the desired goal from the calculated result of the formula in the cell represented by this IRange.
changingCell
Specifies the cell to change.

#### Return Value

true if the desired goal is achieved or false if the goal is not achieved.
Remarks

This GoalSeek method uses a simple iterative linear search for a value which, when placed in the cell specified by changingCell, yields a calculated result very close to the specified goal from the formula in the cell represented by this IRange.

The cell represented by this IRange should contain a formula which is directly or indirectly dependant on the cell specified by changingCell.

The cell specified by changingCell will contain the value used to achieve the desired goal if this method is successful.

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2