Partager via


XmlMappedRange.GoalSeek Method

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
Function GoalSeek ( _
    Goal As Object, _
    ChangingCell As Range _
) As Boolean
bool GoalSeek(
    Object Goal,
    Range ChangingCell
)

Parameters

  • Goal
    Type: System.Object

    The value you want returned in this cell.

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"]);
}

.NET Framework Security

See Also

Reference

XmlMappedRange Interface

Microsoft.Office.Tools.Excel Namespace