GoalSeek module

class GoalSeek.GoalSeek

Bases: SpireObject

Represents a Goal Seek operation in Excel.

This class provides functionality to perform Goal Seek analysis, which is used to find the input value needed to achieve a desired result in a formula. Goal Seek works by varying the value in one specific cell until a formula that depends on that cell returns the desired result.

property MaxIterations: int

Gets or sets the maximum number of iterations for the Goal Seek operation.

This property determines how many calculation attempts the Goal Seek operation will make before stopping if it cannot find an exact solution.

Returns:

The maximum number of iterations.

Return type:

int

TryCalculate

Attempts to perform a Goal Seek calculation with default initial guess.

This method tries to find a value for the variable cell that makes the formula in the target cell return the specified target value.

Parameters:
  • targetCell (CellRange) – The cell containing the formula whose value you want to set.

  • targetValue (float) – The value you want the formula to return.

  • variableCell (CellRange) – The cell whose value will be adjusted to reach the target value.

Returns:

An object containing the results of the Goal Seek operation.

Return type:

GoalSeekResult