XmlMappedRange.GoalSeek Method (2003 System)
Calculates the values necessary to achieve a specific goal.
Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)
Syntax
'Declaration
Public Function GoalSeek ( _
Goal As Object, _
ChangingCell As Range _
) As Boolean
'Usage
Dim instance As XmlMappedRange
Dim Goal As Object
Dim ChangingCell As Range
Dim returnValue As Boolean
returnValue = instance.GoalSeek(Goal, _
ChangingCell)
public bool GoalSeek(
Object Goal,
Range ChangingCell
)
Parameters
- Goal
Type: System.Object
The value you want returned in this cell.
- ChangingCell
Type: Microsoft.Office.Interop.Excel.Range
Specifies which cell should be changed to achieve the target value.
Return Value
Type: System.Boolean
true if the goal seek is successful; otherwise false.
Remarks
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.
Examples
The following code example uses the GoalSeek method to find the cubic root of 27 and places the answer in cell A1. This code example assumes that the current worksheet contains an XmlMappedRange named CustomerAddress1Cell with a corresponding schema element of type int.
Private Sub SolveFormula()
Me.CustomerAddress1Cell.Formula = "=(A1^3)"
Me.CustomerAddress1Cell.GoalSeek(27, Me.Range("A1"))
End Sub
private void SolveFormula()
{
this.CustomerAddress1Cell.Formula = "=(A1^3)";
this.CustomerAddress1Cell.GoalSeek(27, this.Range["A1", missing]);
}
Permissions
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.